![]() |
Attention | Topic was automatically imported from the old Question2Answer platform. |
![]() |
Asked By | ZUHAYR RUSHD |
I want to get a signal in the “level_generator” script whenever the area node in “i”,“ii” and “iii” detects a collision. As you can see I also attached a script “Area_Lev” in the area node which is emitting a signal when it detects collision but the “level_generator” isn’t receiving it.
Level_generator.gd:
onready var Leviv = $iv/RootNode
var last_pos = 0
var new_lev = Levi
func _ready():
$i/RootNode/Plane002/StaticBody/Area.connect("game_over",self,"game_over")
$ii/RootNode/StaticBody/Area.connect("game_over",self,"game_over")
$ii/RootNode/StaticBody/Area.connect("game_over",self,"game_over")
$ii/RootNode/StaticBody/Area.connect("game_over",self,"game_over")
func _process(delta):
var val = rand.randi_range(1,4)
if val == 1:
new_lev = Levi.duplicate()
elif val == 2:
new_lev = Levii.duplicate()
elif val == 3:
new_lev = Leviii.duplicate()
elif val == 4:
new_lev = Leviv.duplicate()
add_child(new_lev)
new_lev.rotation_degrees.y = 90
new_lev.translation = Vector3(last_pos + 19.8, 0, 0)
last_pos += 19.8
func game_over():
print('game_over')
Arealev.gd:
extends Area
signal game_over
func _on_Area_body_entered(body):
emit_signal("game_over")
file donwnload:
https://drive.google.com/drive/folders/1Wpr9PJLod_U0lUdKWiJqNdNWsXwJqJUB?usp=sharing
you did not specify a “Area” or “body”
func _ready():
$Area.connect("body_entered", self, "game_over")
pass
ramazan | 2022-08-18 14:06
format and share the code here please, not everyone cares to download whole projects
Inces | 2022-08-18 19:21
@ramazan
The Area node isn’t a child of the Level_genearator script’s node; i,ii and iii is. I put the location like this $i/RootNode/Plane002/StaticBody/Area
which I believe is directing to the Area node.
ZUHAYR RUSHD | 2022-08-19 07:06