23 lines
560 B
GDScript
23 lines
560 B
GDScript
extends StateAnimatedActor
|
|
|
|
export (NodePath) var idle_node
|
|
|
|
onready var idle_state: State = get_node(idle_node)
|
|
|
|
func process_physics(delta: float) -> State:
|
|
parent.velocity.y += gravity * delta
|
|
|
|
parent.velocity.x = move_component.desired_movement_vector.x * move_speed
|
|
parent.velocity = parent.move_and_slide(parent.velocity, Vector2(0, -1))
|
|
|
|
if parent.velocity.x > 0:
|
|
parent.direction.x = 1
|
|
elif parent.velocity.x < 0:
|
|
parent.direction.x = -1
|
|
|
|
parent.transform.x.x = parent.direction.x
|
|
|
|
if parent.is_on_floor():
|
|
return idle_state
|
|
return null
|