How to line up player animation with button press?

Hey y’all I’m super new to this so I apologize if it’s a very simple issue.

I’m trying to make it so my player can do a flip when A is pressed. I can swap in the animation, but the timing of the button press doesn’t always match up with the sprite, so it sometimes starts in the middle. Is there a way I can make it so it always starts at the beginning?

Here’s my code:

on confirm do
ignore
swap "playerFlip"
wait 0.6666 then
swap "playerFront"
listen
end
end

Play solves both of your problems by playing the animation from the begining and do something else after it ends.

on confirm do
   ignore
   play "playerFlip" then
      swap "playerFront"
      listen
   end
end
1 Like

That worked perfectly! Thank you! :slight_smile: