Animations looping, but looping is off

Godot 4.3.0

Hello, i’m trying to make a simple shooter for my friends. I wanted to make it like a warzone shooting range with targets. I got a weapons and trying to make targets. I got the animations but they’re always looping, but looping is off

Here’s my script for a target:

extends CharacterBody3D

var hp = 100.0
var damage = 15.0
var knife_damage = 100.1

func _physics_process(delta):
if hp <0:
$AnimationPlayer.play(“falll”)
$Timer.start()

move_and_slide()

func _on_timer_timeout():
$AnimationPlayer.play(“up”)
hp = 100

It is probably because you are repeatedly calling play on it. Add a flag like “final_animation_started” which is a boolean. When you start the animation set it to false, and only call the animation if “final_animation_started” is true. Then it will only be called once.

Which animation is looping?

fall animation is looping

var final_animation_started = false

func _physics_process(delta):
if hp <0:
if final_animation_started == true:
$AnimationPlayer.play(“falll”)
$Timer.start()
like this??

Something like that. Here is a better example:

var falll_animation_started: bool = false

func _physics_process(delta):
   if hp <= 0 and not falll_animation_started:
      $AnimationPlayer.play(“falll”)
      $Timer.start()
      falll_animation_started = true

Another alternative depending on the rest of your code would be to stop the physics process entirely:

func _physics_process(delta):
   if hp <= 0:
      $AnimationPlayer.play(“falll”)
      $Timer.start()
      set_physics_process(false)

PS Hopefully this is the reason your animation is looping. It might not be this… sorry if this does not fix it.

oh thank u so much! It started working normally

1 Like