I don't know why my enemy falling off and doesn't play dead animation

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By malaka

Bullet

func _on_Bullet_body_entered(body):
if "Enemy" in body.name:
	body.dead()
queue_free()

Enemy

func dead():
is_dead = true
velocity = Vector2(0,0)
$AnimatedSprite.play("dead")
$CollisionShape2D.set_deferred("disabled",true)
$Timer.start()

I wrote this codes via a tutorial and its actually worked but there is some problems in it. In the video he shoots the enemy and enemy play dead animation, removing his collision and stay on the floor but in my game when i shoot the enemy its falling and doesn’t play the dead animation

Your code looks correct. Maybe you can upload an example project with the issue?

njamster | 2020-06-01 22:38

:bust_in_silhouette: Reply From: ArthyChaux

What is $AnimatedSprite ? Don’t you have an Animation Player ?

That’s not an answer. It’s hardly a comment actually. If malaka wouldn’t have a node with that name, it would throw an error. And given the name, it’s very likely not an AnimationPlayer, but an AnimatedSprite.

njamster | 2020-06-01 22:37

:bust_in_silhouette: Reply From: malaka

i dont know but why i just deleted the whole enemy and i watched the tutorial again now thats works i think its a bug because i just deleted the original enemy and there was an only a copy of its