Godot Version 4.1.1
`
my game crashes when i try and run it
here
Question is the script
extends CharacterBody2D
const SPEED = 300.0
const JUMP_VELOCITY = -400.0
const GRAVITY = 980.0
@onready var animated_sprite = $AnimatedSprite2D
func _physics_process(delta: float) → void:
# Add gravity
if not is_on_floor():
velocity.y += GRAVITY * delta
# Handle jump
if Input.is_action_just_pressed("ui_accept") and is_on_floor():
velocity.y = JUMP_VELOCITY
animated_sprite.animation = "jump"
# Handle horizontal input
var direction := Input.get_axis("ui_left", "ui_right")
if direction:
velocity.x = direction * SPEED
animated_sprite.flip_h = direction < 0
animated_sprite.animation = "run"
else:
velocity.x = move_toward(velocity.x, 0, SPEED)
if is_on_floor():
animated_sprite.animation = "idle"
# Move the character
velocity = move_and_slide(velocity, Vector2.UP)
# Play animation
animated_sprite.play()
link to video :Microsoft OneDrive
please can someone point me in the right direction