How to control statemachine using one boolean variable?

Godot Version

4.2.1

Question

my character has ground state and air state.

i want air animation play when “is_air” condition is true and playing ground animation when “is_air” condition is false.

i found some tutorial video for godot’s animation statemachine, but there are use two bool variable like “is_air” and “is_ground”.

so, is there any approach can change state using one variables?

best regards.

It’s possible by setting the AnimationTree.advance_expression_base_node property to point to the Node that has the script attached and then use the AnimationNodeStateMachineTransition.advance_expression to write your expression to advance.

For example, in your ground to air transition you’ll put is_air == true or just is_air and in your air to ground transition you’d do is_air == false or not is_air

You can also use functions if you want, they have to return true or false

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