I was following a tutorial and the tutorial got to the part where you animate jumping and when every my character jumps while moving it plays the move animation instead of the jumping animation and if you really look it looks like it tries to play the idle animation for a split second during the jump. How do i fix this? Code:
extends CharacterBody2D

@export var speed = 100.0
@export var jump_velocity = -160.0
@export var double_jump_velocity : float = -100

@onready var animated_sprite : AnimatedSprite2D = $AnimatedSprite2D

Get the gravity from the project settings to be synced with RigidBody nodes.

var gravity = ProjectSettings.get_setting("physics/2d/default_gravity")
var has_double_jumped : bool = false
var animation_locked : bool = false
var direction : Vector2 = Vector2.ZERO
var is_in_air : bool = false

func _physics_process(delta):

Add the gravity.

if not is_on_floor():
velocity.y += gravity * delta
is_in_air = true
else:
has_double_jumped = false

	if is_in_air == true:
		land()
		
	is_in_air = false

# Handle Jump.
if Input.is_action_just_pressed("jump"):
	if is_on_floor():
		Jump()
	elif not has_double_jumped:
		velocity.y = double_jump_velocity
		has_double_jumped = true

# Get the input direction and handle the movement/deceleration.
# As good practice, you should replace UI actions with custom gameplay actions.
direction = Input.get_vector("left", "right", "up", "down")


if direction:
	velocity.x = direction.x * speed
else:
	velocity.x = move_toward(velocity.x, 0, speed)

move_and_slide()
update_animation()
update_facing_direction()

func update_animation():
if not animation_locked:
if direction.x != 0:
animated_sprite.play("Run")
else:
animated_sprite.play("Idle")

func update_facing_direction():
if direction.x > 0:
animated_sprite.flip_h = false
elif direction.x < 0:
animated_sprite.flip_h = true

func Jump():
velocity.y = jump_velocity
animated_sprite.play("jump_start")
animation_locked = true

func land():
animated_sprite.play("Jump_end")
animation_locked = true

func _on_animated_sprite_2d_animation_finished():
if(animated_sprite.animation == "Jump_end"):
animation_locked = false

For one thing, your "jump_start" animation will never completely play through, because it is overwritten with the "land" animation in the next physics frame. To prevent that, you probably need another bool variable, preventing the land function to be called before the jump_start animation has finished. Maybe that's already what is confusing you, if the land animation is very short, you go back to running a lot quicker than the character needs to actually finish the jump and land again.

Not sure if that is the only problem here, the code is hard to read since the formatting didn't really work when you copied it.

    Capella Yeah sorry about the weird copied format. But I dont think that is the issue the issue is that the game isnt swicthing to the jump animation when the charcater is running its not about the jump animation changing to the land animation.

      hhll35
      In that case, check if your "jump" function is called at all by putting a breakpoint into it or letting it print some debug output. If not, check, if your is_on_floor function does what you assume it does. Maybe your floor is off by a few pixels or something.