Cannot connect signal through code

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: 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.

onready var Leviv = $iv/RootNode

var last_pos = 0
var new_lev = Levi
func _ready():

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()

    new_lev.rotation_degrees.y = 90
    new_lev.translation = Vector3(last_pos + 19.8, 0, 0)
    last_pos += 19.8

func game_over():

extends Area

signal game_over

func _on_Area_body_entered(body):

file donwnload:

you did not specify a “Area” or “body”

func _ready():
	$Area.connect("body_entered", self, "game_over")

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

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

:bust_in_silhouette: Reply From: Inces

Are You sure collision is even detected within areas ? Place print there.

I tried putting print in the and it does collide.

ZUHAYR RUSHD | 2022-08-19 12:55

Try to connect only one of these areas and check if its collision triggers game_over function in main script

Inces | 2022-08-19 13:05

still the main script doesn’t trigger function game_over

ZUHAYR RUSHD | 2022-08-20 05:13

no way… :slight_smile:
Is main script autoloaded ?
Try printing is_connected for those signals

Inces | 2022-08-20 07:32