Blobby/src/Actor/PlayerStateMachine.gd

31 lines
668 B
GDScript

extends StateMachine
# Adds the intial states
func _ready():
add_state("idle")
add_state("run")
add_state("jump")
add_state("fall")
print_debug(states)
set_state(states.idle);
# Calls the parent behaviours according to state
func _state_logic(delta):
parent.get_node("CollisionShape2D/RayCaster")._raycast(Vector2.DOWN, parent.get_node("CollisionShape2D").get_shape(), parent.collision_mask)
parent.apply_movement(delta)
# Determines which state should be active at the moment
func _get_transition(delta):
return null
func _enter_state(new_state, old_state):
pass
func _exit_state(old_state, new_state):
pass