pantin

A graph for a game

A game does not choose animations: it says how fast Pip goes, and a graph of states chooses for it. Pip stands while it is still and walks while it moves, crossfading from one to the other.

Chapter 8 of 910 minutesFlow workspace

Two states and a number

  1. Open the tab Flow of the bar.
  2. Press + State twice: a state that plays idle, then one that plays walk. The wedge on the left of idle says it is the entry, the state Pip starts in.
  3. Press + Parameter and choose Number: a parameter named speed, which the game will set.
Two states added in the Flow workspace, and the parameter speed
Two states, idle and walk, and the number speed.

The ways between them

  1. Take the Link tool (L) and drag from idle to walk: a transition, chosen. Under When, press + Condition: speed is above 0.
  2. Drag from walk back to idle, press + Condition, and choose is in place of is above: back to the idle when speed is 0.
  3. Each transition fades over 0.2 s; its Crossfade sets how long.
Two transitions drawn with the Link tool, each with its condition on speed
From idle to walk while speed is above 0, and back when it is 0.

Play it as a game would

Play the graph plays Pip in the corner of the canvas, from its entry, the state it is in lit. Type 1 beside speed under Play: Pip walks. Type 0: it stands again. A game does the same with set_number("speed", …) on the node of the Godot runtime, or on the character of the Bevy runtime, and the graph is saved in flow.json beside the project.

The graph played: Pip walks when speed is 1 and stands when it is 0
The graph played, the speed set by hand.

All of this is in States for a game, in the manual.