0 votes

Hey there !
I want to trigger an animation when at least 1 enemy is with in range of my building.
Everything works great but the animation will play only once and never again.

I have read about having to .stop() it before it even start and many other "hints" here an there. But nothing works...

It will play once and that's it. (The animation isn't loop).
I checked my code and the "print" is being triggered every single time. so i figured so should the animation. but no..

func find_multi_target(multi_target_amount, range_attack = 1):
#This function finds X targets in range and shoot at "multi_target_amount" of them
if can_shoot: #cooldown is good to go
    var units
    units = get_overlapping_bodies()
    if units.size() > 0: #we have at least a target.
        if ranged_attack == 0:
            #$melee_animation.show()
            $melee_animation.stop()
            $melee_animation.play("RING_FIRE")
            print("Why not playing ?")

the rest of the function isnt here as it serve no purpose.
Am i formulating this wrong ? I don't get it. Do I need to reset the frame to 0 ?
Thanks !

in Engine by (184 points)

1 Answer

0 votes
Best answer

Lovely. I questioned the fact of setting my frame to 0 after the animation was done.
And it's working :

$melee_animation.frame = 0

thx !

by (184 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.