0 votes

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 Global.world != 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.

Godot version v3.2.3 stable.official
in Engine by (47 points)

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.

What is Global? Is Global Singleton?

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

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

Please log in or register to answer this question.

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 Frequently asked questions and 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 [email protected] with your username.