0 votes

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

asked May 30 in Engine by malaka (32 points)

Try changing
If "Enemy" in body.name
To
If body.name == "Enemy"

Same,its still falling down and doesn't play dead animation

1 Answer

0 votes

Maybe it's deleting the body once the animation starts and it's happening so fast it seems like the animation not playing.maybe delete the body once the animation has finished instead

answered Jun 1 by Ogeeice (160 points)

i dont know how to fix this also in the tutorial everything works and is there a any solve to falling down from walls

i mean its not freeze when he dies

Ok try removing the queuefree() and see if it works. Then if it does play the animation move the queuefree() to under the timer

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 How to use this Q&A? before posting your first questions.