Animation fails after calling "replaced_by" on a node3D

Godot Version

4.2.1 mono

Question

Hi,
So I have a Node3D in a scene that I set an animation with, it was ok. But then I dynamically replaced this node with another nodes in the code by “replaced_by()”. But then the animation doesn’t work anymore after the replacement. I wonder if this is related with how the animation player store the data. If so, what would be the best way to work around?
Anyone has idea?
Thanks!

I think You should avoid use of it? why you needed use? you can add scene with own animations.

yeah… probably a bad idea to replace the node, the underlying data is possibly messed up. But just wonder why. It could be good to know.

Animations use NodePaths to link each track to the values that need to be animated. When you replace or reparent a node at runtime the NodePath in the Animation won’t be updated and will be invalid making the animation to not work.

A workaround would be to use and animate a parent node of the node you want to reparent/replace at runtime so the NodePath is valid.

2 Likes