@export var max_vel:Vector2 = Vector2(-1,500.0) #跳跃var jump_force = 200
#重力
@export var gravity = 500.0
func jump(delta):
if is_on_floor():
pass
if !is_on_floor():
if velocity.y > 100:
$anim.play("Fall")
if velocity.y < -100:
$anim.play("Jump")
if ((-100<velocity.y)&&(velocity.y<100)):
$anim.play("JumpToFall")
if Input.is_action_just_pressed("Jump"):
if is_on_floor():
velocity.y -= jump_force
if !is_on_floor():
pass
if Input.is_action_just_released("Jump") && !is_on_floor():
if clamp(velocity.y,-100,0):
velocity.y = 0
func use_gravity(delta):
velocity.y += gravity * delta
velocity.y = min(velocity.y,max_vel.y)