godot-platformer-state-machine icon indicating copy to clipboard operation
godot-platformer-state-machine copied to clipboard

A Player state machine demo in Godot.

[Godot] Platformer Player FSM

A Player state machine demo in Godot.

:tv: Video sample

Preview image failed to load!

Features

  • Edge jump tolerance (jump button press)
  • Floor anticipation (jump button press)
  • One-way platforms
  • 6 states

How does it work?

The player finite state machine (aka. PlayerFSM) switches among 6 states:

  • Air (StateAir)
  • Idle (StateIdle)
  • Jump (StateJump)
  • Ladder (StateLadder)
  • Swim (StateSwim)
  • Walk (StateWalk)

Those states inherit from BasePlayerState and the machine is controlled by PlayerFSM.

The player itself (Player.gd), which is a KinematicBody2D node, runs the PlayerFSM every frame.

Extra - Skin selector

Through the tool keyword, it is possible to change player skin before runtime, within the engine editor:

  • SkinSelector

The skins are located in the skins directory.

:tv: Video Sample

Preview image failed to load!