Trouble geting the air animations/ falling and jumping. to work properly

Godot Version

4.7

Question

i am trying to make the jump aniamtion and the animtion befor

e falling a bit then swich to fall aniamtion so when i jump aniamtion jump playes then when the y starst going down the aniamiton that is called before the fallign animtion then after this aniamtion finishes i waant the fallign aniamtion to playa nd loop forever untill i land on the ground now this alreayd works but when i jump it is stuck at frame 0 sma ewhen i swich to aniamtion before falling a bit aniamtion the same problem stuck at frame 0 and it never swiches to fallin animation here is the cood

if not is_on_floor():
	if velocity.y < 0:
		if animation_player.current_animation != "jump":
			animation_player.play("jump")
if not is_on_floor():
	if velocity.y > 0:
		animation_player.play("before fall a bit")
		await animation_player.animation_finished
		animation_player.play("fall")

and this code currently is running inside physics process

and in the video the jump aniamiton may look correct but this si not how ti is supposed to wrok it is stuck at frame same with before falling a bit and the fall animation never plyes because the before fall a bit aniamtion dont even finsih becaus eit is stuck at frame 0

Is this a looping animation? The signal you’re awaiting will never fire if it is a looping animation.

the only looping animation is the fall

Should you not check whether the "fall" animation is playing? With the way it works right now, the "before fall a bit" animation will override the "fall" animation as soon as it starts.

Try introducing an if-statement similar to the one for your jump animation:

var is_anim_windup = animation_player.current_animation == "before fall a bit"
var is_anim_fall = animation_player.current_animation == "fall"
if !is_anim_windup and !is_anim_fall:

Let me know how it goes.

if you meant me writing th ecood like that

if not is_on_floor():
	if velocity.y < 0:
		if animation_player.current_animation != "jump":
			animation_player.play("jump")

	if velocity.y > 0:
		var is_anim_windup = animation_player.current_animation == "before fall a bit"
		var is_anim_fall = animation_player.current_animation == "fall"
		if !is_anim_windup and !is_anim_fall:
			animation_player.play("before fall a bit")

it didnt fix the problem that the animation of jump and before fall a bit are stuck at frame 0 in the animation.

I’m assuming this code is inside _physics_process(), which means it’s running every single frame.

Every frame, when your character is falling, you tell the animation player to start playing
“before fall a bit”, which means the animation restarts on frame 0 every physics frame, and the animation never finishes.

You only need to tell the animation to start once. And since “fall” always follows “before fall a bit”, you can queue it at the same time.

Try this instead:

if not is_on_floor():
	var anim = animation_player.current_animation
	if velocity.y < 0:
		if anim != "jump":
			animation_player.play("jump")
	elif velocity.y > 0:
		if anim != "before fall a bit" and anim != "fall":
			animation_player.play("before fall a bit")
			animation_player.queue("fall")

Also, if your jump animation is shorter than the time it takes to go up, you should use var anim = animation_player.assigned_animation instead of var anim = animation_player.current_animation.
This way, it remembers which animation played last even if it stopped playing and the animation doesn’t restart before you can get to the top of the jump.