Animation Tree conflicting with itself

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Pho

I have a packed scene containing an animation tree and player. A script at the root sets an animation transition based on a changing move mode variable.
public override void _Process(double delta) { //Works until a second instance of this scene is spawned animationTree.Set("parameters/MoveModeTransition/transition_request", current_movement_mode.ToString()); }

This code works perfectly fine until a second scene is instantiated.

If a second scene is spawned the two will start flickering in sync with each other. It’s as if the players are somehow trying to play the same instance of an animation and begin overriding one another every frame despite being separately instantiated instances.

I am unsure what could be going wrong, but the bug currently prevents me from adding more than one NPC to a level at any time.

This seems like it might be more of a problem using _Process to change the state every frame. Perhaps the intention is to change the state when current_movement_mode is changed? For that, wrapping it in a property might be better so logic can be added to the set method and actioned once (or even a signal, or some other conditional logic).

spaceyjase | 2023-06-14 10:34