20 lines
625 B
GDScript
20 lines
625 B
GDScript
extends PlayerGroundState
|
|
## 步行:目标速度 = walk_speed,播 walk。
|
|
|
|
func _enter() -> void:
|
|
var player := get_agent() as Player
|
|
player.motor.target_speed = player.motor.walk_speed
|
|
player.motor.sprinting = false
|
|
player.motor.crouching = false
|
|
player.animation_player.play_state(PlayerAnimator.AnimState.WALK, player.motor.walk_speed)
|
|
|
|
|
|
func _think(_delta: float) -> void:
|
|
var player := get_agent() as Player
|
|
if Input.is_action_pressed("crouch"):
|
|
dispatch(&"crouch_start")
|
|
elif not player.motor.has_move_input():
|
|
dispatch(&"move_stop")
|
|
elif Input.is_action_pressed("sprint"):
|
|
dispatch(&"sprint_start")
|