Files
colors-path/Scenes/states/jump.gd
T

22 lines
567 B
GDScript

extends State
func enter() -> void:
player.jump_buffer_timer = 0
player.coyote_timer = 0
player.velocity.y = player.JUMP_VELOCITY
if player.velocity.y < 0:
player.sprite.play("jump")
func physics_update(delta: float) -> void:
player.velocity += player.get_gravity() * delta
var direction := Input.get_axis("left", "right")
player.velocity.x = direction * player.SPEED if direction else move_toward(player.velocity.x, 0, player.SPEED)
player.move_and_slide()
if player.velocity.y > 0:
state_machine.transition_to("Fall")
func exit() -> void:
pass