A Player state machine demo in Godot.
- Edge jump tolerance (jump button press)
- Floor anticipation (jump button press)
- One-way platforms
- 6 states
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.
Through the tool keyword, it is possible to change player skin before runtime, within the engine editor:
The skins are located in the skins directory.