Invalid call. Nonexistent function 'emit_signal' in base 'Nil'.

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Shortanel

Hi I am working at a space shooter and I have a problem with the collision system.

This is the code:

func _on_Hit_box_area_entered(area):
if area.is_in_group("Enemy"):
	Global.player_alive = false

func _ready():
Global.asteroid = self
if != null:

func instance_node(node, location):
var node_instance = 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.

From what I can tell, the code Global.asteroid.emit_signal("instance_node",explosion,area.global_position) doesn’t work. The Global.asteroid part seems to be causing the “Nil” error.

Ertain | 2021-02-16 23:15

What is Global? Is Global Singleton?

yrtv | 2021-02-17 20:58

I don’t entirely know what the Global object is. But the Global.asteroid property doesn’t seem to exist.

Ertain | 2021-02-18 16:30

yrtv yes it is.
Ertain Global.asteroid is the acces to the asteroid scene in the player scene.
Sorry for late response I’m working much of the day, and… sorry for the english

Shortanel | 2021-02-18 19:05