35 lines
949 B
GDScript
35 lines
949 B
GDScript
extends StateAnimatedActor
|
|
|
|
export (NodePath) var fall_node
|
|
export (NodePath) var idle_node
|
|
export (NodePath) var jump_node
|
|
export (NodePath) var attack_node
|
|
|
|
onready var fall_state: State = get_node(fall_node)
|
|
onready var idle_state: State = get_node(idle_node)
|
|
onready var jump_state: State = get_node(jump_node)
|
|
onready var attack_state: State = get_node(attack_node)
|
|
|
|
func process_physics(delta: float) -> State:
|
|
if move_component.wants_jump() and parent.is_on_floor():
|
|
return jump_state
|
|
|
|
if move_component.wants_shoot():
|
|
return attack_state
|
|
|
|
move_actor_as_desired(delta)
|
|
|
|
# if move_component.velocity.x == 0.0:
|
|
# return idle_state
|
|
|
|
#Flip the character before tha actual move maybe.
|
|
if move_component.get_movement_direction() != 0.0:
|
|
parent.transform.x.x = move_component.get_movement_direction()
|
|
|
|
if move_component.desired_movement_vector.x == 0:
|
|
return idle_state
|
|
|
|
if !parent.is_on_floor():
|
|
return fall_state
|
|
return null
|