Player State Machine #5
Labels
No Label
bug
duplicate
enhancement
help wanted
invalid
question
wontfix
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: OddlyTimbot/AprilGameExample#5
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Add a finite state machine to track the player states and trigger animations.
Create an enumerator that will list all the possible states.
Make a variable to know when the player is jumping up, or has reached the apex of a jump and is falling.
jumpUp:bool = falseAdd two new functions:
handle_stateandhandle_animationUpdate the physics process to include these functions in the player loop.
In the handle_input function, detect a jump request and set the jumpUp variable to true:
Code for handling State:
Code to handle animation:
We need to know when the jump animation has finished so we can set jumpUp to false: