Struggling with Signals (from child to parent)

Godot Version



Hi everyone,

I have a Parent node that I want to receive a Signal with some parameters from it’s Child.

This is what I “achieved” this far (I think i’m hardly making sense of the use of signals) :

So the script for the Child node is basically (i might add that this node is a scene instantiated through code) :

signal detection_over(holding_player : Node3D, holding_balls_count : int)

var current_holding_player : Node3D
var holding_balls_count : int

func set_detection(state: bool):
   if state:
    if !state:
          detection_over.emit(current_holding_player, holding_balls_count)

And the parent node script :

const JACK_DETECT = preload("res://scenes/jack_detection.tscn")

func set_jack_detection():
	var jack_detect = JACK_DETECT.instantiate()

func _detection_over(holding_player, holding_balls_count):
	print(str(holding_player) + str(holding_balls_count))

I must admit that this code doesn’t make much sense to me but I’m really in the mist here, I hope that what i’m trying to do is clear enough to you :sweat_smile:


What is the question actually?

If the problem is that _detection_over() never gets called - I don’t see where set_detection() is actually called. Try debugging with breakpoints.


The question would be : how do I send a signal to a parent node so that this parent would get parameters from his child ?

The code I provided here is just an example so you may understand what i’m trying to do. But as I said I’m pretty lost here so I’m looking for explanations as I couldn’t find (or understand) an example searching the web.

set_detection() is called from the _ready function with true as a parameter (doing this : self.body_entered.connect(_on_body_entered ) then once again in the _on_body_entered() with false as a parameter under a certain condition.
Maybe it’s this condition that is wrong, i’ll be looking into it.

I’m essentially trying to know if the way I made, connected, and emitted signals looks right to you

Also _detection_over() is called from the child this way :

detection_over.emit(current_holding_player, holding_balls_count)

As the the function is connected to the signal in the parent script:


Hope i’m clear it’s making sense as i’m typing

So the problem was indeed that _detection_over() wasn’t called as expected (due to a wrongly set condition)

At last i’m starting to figure it out but i’m glad the way i wrote and called signals was right.

I gave up before checking the most basic errors in my code.

Thank you for your help !

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.