![]() |
Attention | Topic was automatically imported from the old Question2Answer platform. |
![]() |
Asked By | Shortanel |
Hi I try to make a method globally that queue free the enemy and/or player when the life it’s 0. Problem is that i use an animated sprite with an area2d for player and enemies my script beeing attached to the sprite. The method is this:
Methods.gd
func die(area):
area.queue_free()
play_sound("Explosion")
EventBus.emit_signal("instance_node",Global.Explosion,area.global_position)
but when the ememy need to die i get this:
Attempt to call function ‘queue_free’ in base ‘null instance’ on a
null instance.
what I’m thinking is that area is just null or it became null after they collide but I don’t know how to take a reference of what hits the enemy? Any idea