Switch between two State Machines in AnimationTree?

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

Hello, I have two state machines representing a 2D player’s weapon animations in one animationtree, each one of them have their own animations but work the same way.
Basically, I would like to switch state machines from a script everytime I switch weapons.
Thanks in advance.

:bust_in_silhouette: Reply From: davidoc

It sounds like you need to add transitions between the two states and set the Advance Conditions to somehting like “HasWeapon1”, “HasWeapon2”, then in code you set the conditions like this:
animation_tree.set("parameters/conditions/HasWeapon1", false) animation_tree.set("parameters/conditions/HasWeapon2", true)