0 votes

I want to get a signal in the "levelgenerator" script whenever the area node in "i","ii" and "iii" detects a collision. As you can see I also attached a script "AreaLev" 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:

Godot version 3.4.2stable
in Engine by (22 points)
edited by

you did not specify a "Area" or "body"

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

format and share the code here please, not everyone cares to download whole projects

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.

1 Answer

+1 vote

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

by (7,753 points)

I tried putting print in the AreaLev.gd and it does collide.

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

still the main script doesn't trigger function game_over

no way... :)
Is main script autoloaded ?
Try printing is_connected for those signals

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.