|Topic was automatically imported from the old Question2Answer platform.
Hello, I’m new to godot and I’m feeling really stupid right now as I think this is probably a rather easy issue but I need some help, I don’t know if I’m missing something really obvious or I’m approaching this the wrong way.
I have a player scene with a KinematicBody2D as the tree root, with sprite, collision and such as children. I want to make a climb ledge animation, so I thought the best way to do it was to just use the animation player and change there my sprite frames and its position, and update the collision as well in each frame. So far so good, but once I finish my animation, I want to change to the default idle animation, but this changes my position back to the position before playing the climb ledge animation. I’ve tried using a trigger when the animation finish to play the idle animation and change the player position using the translate function but these two things are not done at the same exact time so you can see a strange camera jump for one frame.
What is the proper way to update the position of the player when using animations? I really don’t know what I’m really missing to be honest.
For now I’ve decided to split animation and positioning, so I’m doing animations with the animation player and position changes with Tween. Still interested in what would be the best practice, though.
tsb | 2018-02-06 11:45
Its strange, because if you move a body in animation, you really change its position. For example, if you animate a moving platform and hit play, it will MOVE the platform. So, i think the problem is with your code. Can you post it?
gtkampos | 2018-02-06 14:33
I’ll try to explain myself a little better. I have a sprite and a camera as children of a KinematicBody2D, and what I’m animating are the sprite and camera positions, but what I move in my main scene is actually the KinematicBody2D using move_and_slide.
This means that in the world it works fine when I’m moving, but if I activate that animation what I’m moving is the sprite & camera, not the KinematicBody, so I need to adjust that once the climbing animation is finished. I can’t just animate the KB2D since that resets its position to the original one since it is relative to its parent. I was just translating it after finishing the animation but that makes it have a jump for a frame or so and it’s weird (since what I have to do is to translate and go back to the default idle animation at the same time and it’s just not possible). I have to change it since if I don’t do it the next time I try and play the animation again the body is just going to teleport.
I’m guessing that what I’m doing wrong is actually using the animator to change my position in this particular case, and that I should separate that logic since there is no proper way of changing the KB2D position with the animator, since animating the sprite is just a visual change and is not actually changing the position of my player. Just wanted some insight on the proper way now.
tsb | 2018-02-06 15:18