24 lines
544 B
GDScript
24 lines
544 B
GDScript
extends PlayerState
|
|
|
|
|
|
var next_state: StringName
|
|
|
|
|
|
func _enter(_previous_state_path: String, _data: Dictionary = {}) -> void:
|
|
print("entering walking")
|
|
player.move_and_slide()
|
|
|
|
|
|
func _state_physics_update(_delta: float) -> void:
|
|
var direction: Vector2 = player.get_movement_vector()
|
|
direction = direction.normalized()
|
|
player.velocity = direction * player.max_speed
|
|
|
|
player.move_and_slide()
|
|
|
|
if watch_state([WALKING]): return
|
|
|
|
if direction.y > 0:
|
|
player.sprite.play("walk_down")
|
|
if direction.y < 0:
|
|
player.sprite.play("walk_up")
|