How to localise animation resources to a scene in Godot 4?

Godot 4

I have a scene that I instantiate every time the player takes damage which includes a Sprite2D and an Animationplayer. In the ready(): function of the node it randomises the second frame of an animation and then plays that animation instantly. This works as intended but if the same node is already in a scene while a node is being added to it, it randomizes the animation again when the new scene is added, causing the keyframes of the already existing scene to also be randomized and causing the sprite to shift and jitter suddenly as a result.

Iā€™ve tried to make the instantiated scene have all itā€™s resources be ā€˜local to sceneā€™ but that doesnā€™t seem to work for some reason? Any people with the same question seem to be from when Godot was in 3.0, so I wonder if things have changed in Godot 4?

Maybe a Tween would be apt, how complex is your animation?

Each animation is itā€™s own sub-resource within an Animation Library resource, Iā€™m not sure the Animation resource is accessable within the editor, so setting ā€œLocal To Sceneā€ on that specific depth of resource is at least difficult, and maybe only possible by creating an AnimationLibrary viascripts.

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.