34 lines
970 B
GDScript
34 lines
970 B
GDScript
extends StateAnimatedActor
|
|
|
|
export (NodePath) var fall_node
|
|
export (NodePath) var idle_node
|
|
export (NodePath) var attack_node
|
|
export (NodePath) var jump_node
|
|
|
|
onready var jump_state: State = get_node(jump_node)
|
|
onready var fall_state: State = get_node(fall_node)
|
|
onready var idle_state: State = get_node(idle_node)
|
|
onready var attack_state: State = get_node(attack_node)
|
|
|
|
func process_physics(delta: float) -> State:
|
|
|
|
# if move_component.wants_shoot():
|
|
# return attack_state
|
|
|
|
if move_component.wants_jump():
|
|
return jump_state
|
|
|
|
move_component.velocity.y += gravity * delta
|
|
#parent.velocity = parent.move_and_slide(parent.velocity, Vector2(0, -1))
|
|
move_component.velocity.x = parent.transform.x.x * move_speed
|
|
move_component.velocity = parent.move_and_slide(move_component.velocity, Vector2(0, -1))
|
|
|
|
|
|
if move_component.velocity.x == 0.0 or animations.playing == false:
|
|
if !parent.is_on_floor():
|
|
return fall_state
|
|
else:
|
|
return idle_state
|
|
|
|
return null
|