Playmaker Forum

PlayMaker Help & Tips => PlayMaker Help => Topic started by: Gav (HeyBud) on September 18, 2018, 01:06:57 AM

Title: Rotate a sprite with an arrow in Z from Horizontal and Vertical Axis?
Post by: Gav (HeyBud) on September 18, 2018, 01:06:57 AM
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.
Title: Re: Rotate a sprite with an arrow in Z from Horizontal and Vertical Axis?
Post by: jeanfabre on September 18, 2018, 02:43:36 AM
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
Title: Re: Rotate a sprite with an arrow in Z from Horizontal and Vertical Axis?
Post by: Gav (HeyBud) on September 28, 2018, 02:22:05 PM
Hi Jean, I still need to try this. I'll post a reply as soon as I know. Thanks for your help!
Title: Re: Rotate a sprite with an arrow in Z from Horizontal and Vertical Axis?
Post by: 4arrancho on January 09, 2019, 07: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