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

in Engine by (36 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

by (36 points)
0 votes

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

by (38 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.
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 webmaster@godotengine.org with your username.