Make AnimationNodeAnimation unique

Godot Version

v4.2.1.stable.mono.official [b09f793f5]

Question

I have this function that changes the animation contained inside an AnimationNodeAnimation:

public void SetAnimation(string animName)
    {
        AnimationNodeAnimation animNode = (AnimationNodeAnimation)User.c.animationStateMachine.GetNode("Ability");
        animNode.Animation = (User.animLibrary+"/"+animName);
    }

The problem is that it seems to change it for every instance of the animationTree, rather than for just the one attached to the “User”. I already made the AnimationNodeAnimation Local to the scene, but I still have this issue.

You probably need to make any Resource in between until you reach the AnimationNodeAnimation Resource also local to the scene.

What do you mean by in between? I tried making the AnimationNodeTransitions, and the other AnimationNodeAnimations in the animationtree local, but it doesn’t seem to fix the issue.

Every Resource from the AnimationTree.tree_root until you reach the AnimationNodeAnimation you want to change.

Thank you, this seems to have fixed my issue

I’m pretty new to Godot, would it be possible to give more detail on how you set every resource as local-to-scene?

I’m having an issue where I’m programmatically modifying the value of some property tracks on an animation in a specific case, and in every node and transition in my animation tree I have manually checked “Local To Scene”, but these modifications still seem to apply to every instance of the scene with the animation player / tree as children.

Did you traverse the animation tree from the root node in code and find things that needed to be local-to-scene besides the nodes and transitions?

I’ve not tested this but, if you are modifying an Animation Resource I think you’ll need to make local to the scene the AnimationLibrary that animation is in and the Animation itself.

Appreciate the response!

From what I’ve set in the editor, each Animation as seen in the AnimationPlayer has been set as local to scene, every node / transition in the animation tree, the animation library resource in the AnimationPlayer, and the TreeRoot resource in the AnimationTree. Is there something buried somewhere I might be missing?

I don’t know then, sorry.

I had a similar problem and it seems that currently duplicating animations or setting them local to scene does not work. There is an open issue on Github.

Setting resources local_to_scene / duplicating resources isn’t very reliable right now in my opinion. For example, it doesn’t work if resources are in an array (see this issue). I’ve wasted a lot of time because of that. I ended up creating custom methods for duplicating resources. I really hope those bugs get fixed soon because they are very confusing.

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