How to implement player jump animation

Godot Version

Godot_v4.2.2-stable_win64.exe

Question

Hey, my beginner self is back with yet another question. I’m trying to implement jump animation and I’m doing it like so:

func _physics_process(delta):
	# Add the gravity.
	if not is_on_floor():
		velocity.y += gravity * delta
		player.play("Jump")

But the thing is, my player is Idle when in the air, how do I correctly implement this?

You need to make sure other animations do not play during the jump animation. Only play “Idle” if the player is_on_floor for instance.

1 Like

Lemme try this, I will tell you how it goes. Thanks for responding…

It worked! I later did like so:

	if is_on_floor():
	# Play animation based on direction
		if direction == 0:
			player.play("Idle")
		elif direction == 1 or direction == -1:
			player.play("Run")
	else:
		player.play("JumpStart")

Thanks for the insight.

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.