# playMaker

### Author Topic: Rotate a sprite with an arrow in Z from Horizontal and Vertical Axis?  (Read 500 times)

#### Gav (HeyBud)

• Full Member
• Posts: 117
##### Rotate a sprite with an arrow in Z from Horizontal and Vertical Axis?
« on: September 17, 2018, 10:06:57 PM »
How do I convert X and Y Input Axis to a Z rotation on a sprite. I want the arrow sprite to rotate in the same direction as the analog stick.

#### jeanfabre

• Hero Member
• Posts: 14703
• Official Playmaker Support
##### Re: Rotate a sprite with an arrow in Z from Horizontal and Vertical Axis?
« Reply #1 on: September 17, 2018, 11:43:36 PM »
Hi,

one way is to have a dummy 'InputDummy' that move in absolute mode compare to your input ( so it will range around it's parent between -1 and 1 on x an y)

the you make another dummy where you have the sprite as a child of it, and make that dummy look at that 'InputDummy'.

else, mathematically, this is a matter of understanding sinus and cosinus.

https://www.mathsisfun.com/algebra/trig-finding-angle-right-triangle.html

so in your case, you want the angle between the hypotenuse and adjacent, but it's a lot more involving because you need some math to get a proper angle around the four quadrant.

Bye,

Jean

#### Gav (HeyBud)

• Full Member
• Posts: 117
##### Re: Rotate a sprite with an arrow in Z from Horizontal and Vertical Axis?
« Reply #2 on: September 28, 2018, 11:22:05 AM »
Hi Jean, I still need to try this. I'll post a reply as soon as I know. Thanks for your help!

#### 4arrancho

• Playmaker Newbie
• Posts: 26
##### Re: Rotate a sprite with an arrow in Z from Horizontal and Vertical Axis?
« Reply #3 on: January 09, 2019, 05:32:17 PM »
Hi did you solve this?

I think this is what you want:

http://hutonggames.com/playmakerforum/index.php?topic=11284.0

The only cons i see in this action is that when the key is not press it rotates to the original position.

For example if we are pressing down the sprite rotates down but when we are not pressing it rotates the sprite to the start position