37 lines
866 B
GDScript
37 lines
866 B
GDScript
extends State
|
|
|
|
export (NodePath) var idle_node
|
|
|
|
onready var idle_state: State = get_node(idle_node)
|
|
|
|
func enter() -> void:
|
|
.enter()
|
|
parent.velocity.x = 0
|
|
parent.set_hurtbox(false)
|
|
#TODO: Error check if timer was actually instanced
|
|
state_timeout.start()
|
|
|
|
func process_input(_event: InputEvent) -> State:
|
|
# move_component.wants_jump()
|
|
move_component.get_movement_direction()
|
|
|
|
return null
|
|
|
|
|
|
func process_frame(delta: float) -> State:
|
|
if state_timeout.time_left == 0:
|
|
return idle_state
|
|
return null
|
|
|
|
|
|
func process_physics(delta: float) -> State:
|
|
parent.velocity.y += gravity * delta
|
|
#parent.velocity = parent.move_and_slide(parent.velocity, Vector2(0, -1))
|
|
if (parent.direction.x > 0):
|
|
parent.velocity.x = 1 * move_speed
|
|
else:
|
|
parent.velocity.x = -1 * move_speed
|
|
parent.velocity = parent.move_and_slide(parent.velocity, Vector2(0, -1))
|
|
|
|
return null
|