Animation that change positions moving foward

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By arthurZ

Hi, I have a sprite animation made in Animation Player of an attack that stays in the same position, but I want this animation to move forward (right or left) when the attack button is pressed and then after the end of the animation the character could be controlled again by the player at the position that it is leaved.

The problem is that I can do the animation to move in the Animation Player changing the Player node position, but then it gets decentralized in the Player node (KinematcBody2D) and I do not want to restart the position, I want that the player moves the character from the position that the animation ended.

I saw some posts saying to put the Player inside another node and make the animation from that, but I did not quite understand how. Would anyone have a tutorial or an example?

Thank you.

Note: I have the others animations working (run, jump).

Why not handling movement apart from animation? I mean, like seting a bool called attacking that you set to true when player is attacking. Then, in the part you handle movement, if it is attacking you do the movement you want instead of the normal movement you would do if not attacking. I dont know if im making myself clear, bu i always do like that.

p7f | 2019-01-25 11:02

Hi, p7f. I will clean the script later, I’m still making some tests.

The problem that I’m talking about is more about Animation Player in godot, it’s easy to make an attack animation in which the attack is done in the same position, but what if I want an attack that the player moves forward?

What I’m trying to say is how to move the player node to get an animation like the link below and regain the control at the end of the animation in the last frame position?

The example of animation that moves foward:

enter image description here

I managed to do what I asked for in the OP but I believe there are more sophisticated ways of doing this. My solution was only animating the Position and Frame values in the Sprite Node making at the end the player node to jump to the last frame of the sprite node position in the script.

What I want is to animate the sprite (in the same position) and also using the player node to make each frame of this animation advance some positions as I like.

Thanks again.

arthurZ | 2019-01-25 15:03