My instanced scene is animating to global location rather than local location. Help!

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Robster
:warning: Old Version Published before Godot 3 was released.

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! :slight_smile:

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.

avencherus | 2016-10-22 03:11

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.

ericdl | 2016-10-22 03:44

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.

Robster | 2016-10-23 02:02

:bust_in_silhouette: Reply From: Zylann

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.

Great response thank you.

Robster | 2016-10-23 02:01