playMaker

Author Topic: Flipping sprites for direction object is headed into? [SOLVED]  (Read 1760 times)

Just

  • Playmaker Newbie
  • *
  • Posts: 41
Flipping sprites for direction object is headed into? [SOLVED]
« on: September 20, 2017, 06:14:00 AM »
Hello,

What is the most reliable way to get sprite facing direction it's headed into? So far I have used Get Key Down command to get sprite face direction pressed in arrow key. However, I have some movements in game (such as wall jump) that makes it not always face right way when it reaches in ground.

Example: you hold arrow key, sprite lands faced on opposite direction, sprite moves direction indicated by arrow key input, but Get Key Down-command doesn't activate for flipping sprite until you release and press arrow key again.



« Last Edit: September 21, 2017, 05:31:19 AM by Just »

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Flipping sprites for direction object is headed into?
« Reply #1 on: September 20, 2017, 07:28:15 AM »
Hi,

 the most reliable way is to get the velocity of the GameObject and then check the x value, if it's negative then you flip the sprite, if it's positive you don't flip it.

 this way no matter happens, the sprite will always face the direction it's heading too, however if you have some bouncing back or similar behavior you will be better off using user Inputs as the source for flipping sprites.

 Bye,

 Jean

Just

  • Playmaker Newbie
  • *
  • Posts: 41
Re: Flipping sprites for direction object is headed into?
« Reply #2 on: September 21, 2017, 05:29:50 AM »
Thanks, that was exactly what I needed, now it's working perfectly!