Hi! I’m creating a top-down RPG in the style of the old ‘Legacy of Goku’ games. My sprite can walk left, right, toward the camera and away from it. When my sprite stops walking, he returns to the idle pose, animation #0, where he is facing the camera.
However, I’d like for my sprite to keep facing the direction he was walking in before stopping. For example, if he is walking leftward toward an item such as a treasure chest or a boss he’s about to fight, it looks a bit silly for him to turn and face the camera as soon as the motion stops.
I’m aware I could invert at the end of motion and have him return to a static idle animation in which he’s facing left, but then he’s always going to be flipping back to a left facing position.
In summary, when my sprite has finished walking in any direction, I’d like them to keep facing that direction on returning to idle.
Add an action, set a sprite variable for whenever you move to the angle of movement, I.e if moving left set variable to 180. Then condition is player idle. Set angle of sprite to Variable.
if pressed right key, change animation to right
if pressed left key, change animation to left
and so on
Am I missing something here? Why can’t you just find the event that sets the idle animation and comment it out? That should keep the animation to the last direction the character was moving.
Thanks for the replies guys but still no luck. I have attached a pic of how my events are set up. The 0 value represents the idle animation facing the camera. As you can see with the bottom event, the Goku sprite switches back to the 0 value after movement is stopped. I can’t work out how to make that so he faces whatever direction he was walking in when the walking stops.
I’ve tried the advice above but not sure I understand how to do that.
Hi, not too sure what that means, sorry. I’m new to gdevelop
You can try right click your “Goku is NOT moving” event and click “Toggle Disabled”.
You can also press right click then T
Yes,. Either that, or delete the whole event.
Thanks, unfortunately I’m using a Mac and don’t have that toggle option on right click. I tried deleting the event and while the sprite could still slide around, the walking animations all stopped
When right key is pressed, sprite walks right and it displays the correct rightwards walking animation, but once the movement stops the sprite flips back to facing the camera again
when keys are pressed change animation, keys are released change animation to where you want player to face
maybe you can keep idle animation next to right_moving animation and after keys are released, change animation - 1
Oh awesome, that did the trick! Thanks a million!