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)

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

2 Answers

0 votes
Best answer

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

answered Jun 2 by malaka (32 points)
0 votes

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

answered Jun 1 by ArthyChaux (34 points)

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.

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.