I have no Idea whats Happening... Please send help!

Godot Version

4.3 Stable

So, I’m trying to create a jumppad in my game (it already works) and now I want to animate it. I am using the following script for everything, but once the player steps on the jumppad it just loops the animation?

extends StaticBody2D

@export var jump_force: float = 400.0
@onready var anim: AnimatedSprite2D = $AnimatedSprite2D

func _ready() -> void:
	pass


func _process(delta: float) -> void:
	pass


func _on_area_2d_body_entered(body: Node2D) -> void:
	if body.name == "Player":
		body.velocity.y = -jump_force
		if body.velocity.y < -0.001:
			anim.play("ForceUp")
		else: if body.velocity.y == 0:
			anim.play("ForceDown")

1 Like

Do the opposite of this to stop the looping.

@ThisGameIsRyan thanks bud, that was the solution. however it does not play the second animation when the body reaches zero velocity (i dont like the way that is managed anyway, is there a wait() function in gdscript?)

Yeah, there are two ways:

  1. Do it through code Is there a wait function to godot
  2. Do it through nodes and signals Timer — Godot Engine (stable) documentation in English
1 Like

@ThisGameIsRyan works perfectly thanks

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