playMaker

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

Gav (HeyBud)

  • Full Member
  • ***
  • Posts: 117
    • View Profile
    • Tumblr
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

  • Administrator
  • Hero Member
  • *****
  • Posts: 13891
  • Official Playmaker Support
    • View Profile
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
    • View Profile
    • Tumblr
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: 25
    • View Profile
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