Hi I am working at a space shooter and I have a problem with the collision system.
This is the code:
Player.gd:
func _on_Hit_box_area_entered(area):
if area.is_in_group("Enemy"):
Global.asteroid.emit_signal("instance_node",explosion,area.global_position)
area.get_parent().queue_free()
Global.player_alive = false
print(Global.player_alive)
emit_signal("instance_node",explosion,global_position)
queue_free()
Asteroid.gd:
func _ready():
$Hit_box.add_to_group("Enemy")
play()
Global.asteroid = self
if Global.world != null:
connect("instance_node",Global.world,"instance_node")
World.gd:
func instance_node(node, location):
var node_instance = node.instance()
add_child(node_instance)
node_instance.global_position = location
Long story short when the player hit the asteroid instead of playing the explosion animation of asteroid just crashed and this error show. I don't know exactly how to fix it.
Thank you and I wait an answer from you guys.
P.S. what is strange that sometimes works fine.