Animation playing wrong after jumping up a platform

Godot Version

Godot Engine v4.7.1.stable.official

Question

so when i jump up onto a platform, the animations dont exactly play right. the jump animation is completely skipped, and the walk animation gets paused.

heres my code (im so sorry im new)

extends CharacterBody2D

var move_speed : float = 250.0
var jump : float = 300.0
var gravity : float = 500.0
var jumping = 0
var landing = 0
var falling = 0

func _ready() -> void:
	$Timer.timeout.connect(_land)
	$Timer2.timeout.connect(_fall)

func _process(_delta):
	if not is_on_floor() and falling == 1:
		falling = 0
		$AnimatedSprite2D.play("falling")
	elif not is_on_floor()  and jumping == 0:
		$Timer.start()
		$AnimatedSprite2D.play("landing")
	if velocity.x == 0 and is_on_floor() and landing == 1:
		$AnimatedSprite2D.animation = "walk"
		$AnimatedSprite2D.stop()
	elif velocity.x != 0 and is_on_floor() and landing == 1:
		$AnimatedSprite2D.play("walk")

func _physics_process(delta):
	if not is_on_floor():
		velocity.y += gravity * delta
		
	if is_on_floor():
		jumping = 0
		$walkpoly.disabled = false
		$jumppoly.disabled = true
		
	velocity.x = 0
	if Input.is_action_pressed("move_left"):
		velocity.x -= move_speed
		$AnimatedSprite2D.flip_h = true
	if Input.is_action_pressed("move_right"):
		velocity.x += move_speed
		$AnimatedSprite2D.flip_h = false
	if Input.is_action_just_pressed("jump") and is_on_floor():
		$jumppoly.disabled = false
		$walkpoly.disabled = true
		jumping = 1
		landing = 0
		velocity.y = -jump
		$Timer2.start()
		$AnimatedSprite2D.play("side")
		if Input.is_action_pressed("move_left"):
			$AnimatedSprite2D.flip_h = true
		if Input.is_action_pressed("move_right"):
			$AnimatedSprite2D.flip_h = false
			
	if Input.is_action_just_pressed("reset"):
		position.y = 0
		position.x = 540
		velocity.y = 20
	if Input.is_action_just_pressed("menu"):
		get_tree().change_scene_to_file("res://title_screen.tscn")
	move_and_slide()
	
func _land():
	falling = 0
	landing = 1
func _fall():
	landing = 0
	falling = 1

Hi! The reason is in your 3rd conditional in the process func im guessing you play an idle animation by taking the first frame of your walking animation and pausing it. But at that point why not just make a seperate idle animation? Since you made 2 if elifs instead of 1 if elif your walking check is running after your jump check so it gets overidden. Also, if you really are keen on using the state checks like landed or falling why not use booleans? Its the same thing just a lot simpiler than setting a int to 1s and 0s (that’s why we have bools lol). Anyway hope this helps!

i got it working after posting, but heres what i fixed

extends CharacterBody2D

var move_speed : float = 250.0
var jump : float = 300.0
var gravity : float = 500.0
var jumping = 0
var landing = 0
var falling = 0

func _ready() → void:
$Timer.timeout.connect(_land)
$Timer2.timeout.connect(_fall)

func _process(_delta):
if not is_on_floor() and falling == 1:
falling = 0
$AnimatedSprite2D.play(“falling”)
elif not is_on_floor()  and jumping == 0:
$Timer.start()
$AnimatedSprite2D.play(“landing”)
if velocity.x == 0 and is_on_floor():
$AnimatedSprite2D.animation = “walk”
$AnimatedSprite2D.stop()
elif velocity.x != 0 and is_on_floor():
$AnimatedSprite2D.play(“walk”)

func _physics_process(delta):
if not is_on_floor():
velocity.y += gravity * delta

if is_on_floor():
	jumping = 0
	
velocity.x = 0
if Input.is_action_pressed("move_left"):
	velocity.x -= move_speed
	$AnimatedSprite2D.flip_h = true
if Input.is_action_pressed("move_right"):
	velocity.x += move_speed
	$AnimatedSprite2D.flip_h = false
if Input.is_action_just_pressed("jump") and is_on_floor():
	jumping = 1
	falling = 0
	velocity.y = -jump
	$Timer2.start()
	$AnimatedSprite2D.play("side")
	if Input.is_action_pressed("move_left"):
		$AnimatedSprite2D.flip_h = true
	if Input.is_action_pressed("move_right"):
		$AnimatedSprite2D.flip_h = false
		
if Input.is_action_just_pressed("reset"):
	position.y = 0
	position.x = 540
	velocity.y = 20
if Input.is_action_just_pressed("menu"):
	get_tree().change_scene_to_file("res://title_screen.tscn")
move_and_slide()

func _land():
falling = 0
landing = 1
func _fall():
landing = 0
falling = 1

i made the walking animations no longer depend on landing, and i set falling to 0 instead of landing to 0 in the jump code