26 lines
724 B
GDScript
26 lines
724 B
GDScript
extends State
|
|
class_name PlayerJump
|
|
|
|
func get_state_name():
|
|
return str(self).split(":")[0]
|
|
|
|
func enter():
|
|
player.ap.play("jump")
|
|
player.velocity.y = -player.jump_force
|
|
func exit():
|
|
pass
|
|
func update(delta):
|
|
|
|
if player.transitionledgegrab():
|
|
Transitioned.emit(self, "PlayerLedgeGrab")
|
|
elif player.transitionfall():
|
|
Transitioned.emit(self, "PlayerFall")
|
|
elif !player.is_on_floor() and Input.is_action_just_pressed("jump") and (player.air_jumps_done < player.max_air_jumps):
|
|
Transitioned.emit(self, "PlayerDoubleJump")
|
|
elif player.is_on_floor() && player.velocity.x != 0:
|
|
Transitioned.emit(self, "PlayerRun")
|
|
elif player.is_on_floor():
|
|
Transitioned.emit(self, "PlayerIdle")
|
|
func physics_update(delta):
|
|
pass
|