extends CharacterBody2D @export var SPEED = 300 @export var GRAVITY = 30 @export var JUMP_FORCE = 500 @onready var animated_sprite = $AnimatedSprite2D; var jumping = false; func _ready(): animated_sprite.play("idle") func _physics_process(delta): if !is_on_floor(): velocity.y += GRAVITY if velocity.y > 1000: velocity.y = 1000 if jumping && is_on_floor(): jumping = false if Input.is_action_just_pressed("jump") && is_on_floor(): velocity.y = -JUMP_FORCE jumping = true animated_sprite.play("jump") var horizontal_direction = Input.get_axis("move_left", "move_right") velocity.x = SPEED * horizontal_direction move_and_slide() animated_sprite.flip_h = horizontal_direction < 0 if !jumping: if is_on_floor() && horizontal_direction != 0: animated_sprite.play("walk") else: animated_sprite.play("idle")