![]() |
Attention | Topic was automatically imported from the old Question2Answer platform. |
![]() |
Asked By | tshrpl |
hi this is my first question so pardon me for any mistakes
i’m trying to make an asteroids clone following this tutorial
i’ve setup two scenes “laser” and “asteroid” each with a script attached to their root nodes
here are the important bits
laser.gd
func _on_laser_body_shape_entered(body_id, body, body_shape, area_shape):
if (body.is_in_group("asteroids")):
print("asteroid hit")
body.call_deferred("explode")
get_parent().remove_child(self)
queue_free()
asteroid.gd
var is_exploded := false
func explode():
print("called exploded")
if is_exploded:
return
is_exploded = true
get_parent().remove_child(self)
queue_free()
i only see asteroid hit in the console, can anybody explain me how to use the call_deferred function, or help me fix the code
edit: here are the project files
var is_exploded := false
func explode():
print("called exploded")
if is_exploded:
return
is_exploded = true
get_parent().remove_child(self)
queue_free()
That’s uhhh pretty hacky code. I suggest following a different tutorial.
func explode():
print("called exploded")
queue_free()
That’s what the code should look like. If he’s planning on incrementing a score then he should check is_queued_for_deletion()
instead of maintaining his own is_exploded
variable. It doesn’t seem like the person that makes that tutorial is well versed in Godot.
timothybrentwood | 2021-05-05 13:19