21 lines
739 B
GDScript
21 lines
739 B
GDScript
extends LimboState
|
|
## 上升段:播 jump。越过顶点(vy ≤ 0)转 Fall。
|
|
## 水平目标速度保持离地前的值 —— 空中加速度本来就小(air_acceleration),
|
|
## 不由本状态改写。
|
|
|
|
func _enter() -> void:
|
|
(get_agent() as Player).animation_player.play_state(PlayerAnimator.AnimState.JUMP)
|
|
|
|
|
|
func _update(_delta: float) -> void:
|
|
var player := get_agent() as Player
|
|
if player == null:
|
|
return
|
|
# 落地判定带 vy ≤ 0 门槛:起跳那一帧 is_on_floor() 还是 true
|
|
# (要等 move_and_slide() 之后才翻假),没有门槛会当帧弹回地面状态。
|
|
if player.is_on_floor() and player.velocity.y <= 0.0:
|
|
dispatch(&"landed")
|
|
return
|
|
if player.velocity.y <= 0.0:
|
|
dispatch(&"falling")
|