0 votes

Hi all,

I have a character. I created him in a scene with a Node2d as his root, then added all his bits n pieces and animated them in that scene. I need to animation position, rotation and scale for the animation to work (moves up and down etc).

I then created another scene, the game level. I put the character into the scene (instanced) and then move the character into place. The character stays in place until I play the animation. At that point the character jumps to where I created the animation in the original scene file.

Can anyone offer some advice as to why that's happening and how I can overcome it?

I noted an old question on this topic and the advice was to remove the position keys, but I need the position keys as I animate the relative position of the character.

Any help GREATLY appreciated on this one! :-)

in Engine by (838 points)

Based on the limited information, my only guesses are that you might be keyframing the wrong properties, or in your character scene you're having the character wander away from the origin.

The animation you do inside the character scene should do it's best to start and end around the center of the root node's origin coordinates. Then above that in the parent scene, you will move the root node to give actual world movement.

But I can't really say for sure.

There is an open issue on github related to this. Bojidar mentions fixing the problem by adding an additional parent Node2d. Just tested it and it works fine for platforms & such but is kinda clumsy for characters.

Thanks to everyone. Embarrassingly it turns out I'd coded some global locations via the level scene when testing a few weeks ago and forgotten about it. Total human error in the end. The thread gave some good info though, so that's always worthwhile.

1 Answer

+2 votes
Best answer

You can fix that problem by not animating any of the properties found in the root Node2D. Because if you do, that node will obviously move relative to whatever its parent is once instanced. I made the same mistake recently but it actually makes sense to not touch the root at all, that's what it is meant to be: make its children local to it.

by (29,120 points)
selected by

Great response thank you.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.