Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | XavierGerD |
Hi,
I have this script that plays a flashing animation when an enemy is hit by a bullet:
func _on_Area2D_body_entered(body):
if isDead: return
if body.get_name() == "BulletType01":
body.queue_free()
if body.get_name() == "PlayerShipRed":
body.playerHit(1)
$EnemyHitAudio.play()
health -= 1
$Enemy01Sprite.play("hit")
if health <= 0:
$Enemy01Sprite.play("explode")
isDead = true
emit_signal("stopPath")
As you can see, I’m trying to trigger another animation when the enemy’s health reaches 0 or below. However, if the hit animation is playing, it seems as though the death animation is not being played. This is confirmed by the fact that the death animation works every time if I comment out the hit animation.
Any help is appreciated,
Thank you!
I cannot reproduce your problem. Can you provide an example project with the issue at hand?
njamster | 2020-05-04 11:25
Of course! Here is a link to the github repo:
GitHub - XavierGerD/Star-Blaster
Just open and run Scene/Main_Game/Main.tscn. Shoot enemies. You should notice death animations are not always playing. The same thing happens if you collide with enemies, your ship should explode but it doesn’t always.
Thanks for your help!
XavierGerD | 2020-05-04 13:01