extends KinematicBody2D export var move_speed := 100 export var gravity := 2000 export var jump_speed := 550 var velocity := Vector2.ZERO func change_animation(): if velocity.x > 0: # right $AnimatedSprite.flip_h = false elif velocity.x < 0: # left $AnimatedSprite.flip_h = true # jumping if velocity.y < 0: $AnimatedSprite.play("jump") else: if velocity.x != 0: $AnimatedSprite.play("walk") else: $AnimatedSprite.play("idle") func _process(delta: float) -> void: change_animation() func _physics_process(delta: float) -> void: # reset motion velocity.x = 0 # movement if Input.is_action_pressed("move_right"): velocity.x += move_speed if Input.is_action_pressed("move_left"): velocity.x -= move_speed # gravity velocity.y += gravity * delta # Apply jump to next frame if Input.is_action_just_pressed("jump"): if is_on_floor(): # negative y is up velocity.y -= jump_speed # move the heccin boi velocity = move_and_slide(velocity, Vector2.UP)