Como fazer as animações de corrida e pulo no scripts em uma jogo 2D na versão da steam ?

Hello, I’m a beginner in Godot programming and that’s why I use the engine’s own basic programming to make the character go forward, backward and jump. When I tried to script the animations it went wrong, because maybe the codes I’m using are a little outdated for the Steam version.

extends CharacterBody2D


const SPEED = 300.0
const JUMP_FORCE = -400.0

# Get the gravity from the project settings to be synced with RigidBody nodes.
var gravity = ProjectSettings.get_setting("physics/2d/default_gravity")
var is_ jumping := false
@onready var animation := $anim as AnimatedSprite2D

func _physics_process(delta):
	# Add the 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_FORCE
   is_jumping = true
elif is_on_floor():
    
   is_ jumping = false

	# Get the input direction and handle the movement/deceleration.
	# As good practice, you should replace UI actions with custom gameplay actions.
	var direction = Input.get_axis("ui_left", "ui_right")
	if direction:
     velocity.x = direction * SPEED
    animation.scale.x = direction
    if !is_jumping:
     animation.play("run")
elif is jumping:
     animation.play("jump")
	
	else:
	   
		velocity.x = move_toward(velocity.x, 0, SPEED)
animation.play("idle")

		
	move_and_slide()

Sorry, I couldn’t post the image but that’s it, I couldn’t solve it, can you help me?

The codes I’m using are: animation.play(“run”) // @onready var animation := $anim as AnimatedSprite2D// var is_ jumping := false// is_jumping = true// animation.scale.x = direction

I’m also using a node: AnimationPlayer