I have scenes A, B and C.

A is the main scene, and scenes B and C are just instanciated in it.

In scene B I have this script:

signal sploosh

func _ready():
	if Input.is_action_pressed("Splash"):
		emit_signal("sploosh")

And in scene C I have this script:

func _ready():
	get_parent().get_node("SceneB").connect("sploosh", self, "asd")
	

func asd():
	print("yay")

But it still is not working as it should. Do I use some deprecated stuff or something?

With print(get_parent().get_node("SceneB").get_signal_list()) from Scene C I can see the sploosh signal though. Signals have been the toughest part to learn for some reason to me.

  • Megalomaniak replied to this.
  • vomppis That is still just as wrong, asd() in turn is still called from ready. Just remove that func _ready(): line and it's contents altogether for now, cause it seems to be confusing you. Having _ready(): in a script is not mandatory.

    And rename that func asd(): to either func _input(): or func _process():.

    Then create a new func asd(): as such:

    func asd():
        print("yay")

    vomppis In scene B I have this script:
    signal sploosh

    func _ready():
    	if Input.is_action_pressed("Splash"):
    		emit_signal("sploosh")

    This is wrong, you don't use Input in _ready() also, I suspect you don't want it to actually emit that signal in that exact moment when the node becomes 'ready' anyways.

    Either do this in _input() or one of the processes but not in ready or in init.

      Is is possible that at the time when C's _ready() func is called, scene B has not been constructed yet? I would try moving the connect call to the parent node A. That way you know both child nodes have been constructed.

        Megalomaniak Yes, after sending the first post, I moved the if block to separate function like this, but it did not solve the problem:

        func _ready():
        	asd()
        
        func asd():
        	if Input.is_action_pressed("Splash"):
        		emit_signal("sploosh")

        Haystack
        I will try if this solves the problem. Do you mean like this to Scene A script:
        get_node("SceneB").connect("sploosh", $SceneC, "asd")

          vomppis That is still just as wrong, asd() in turn is still called from ready. Just remove that func _ready(): line and it's contents altogether for now, cause it seems to be confusing you. Having _ready(): in a script is not mandatory.

          And rename that func asd(): to either func _input(): or func _process():.

          Then create a new func asd(): as such:

          func asd():
              print("yay")

            Megalomaniak Thanks, now it works.
            I need to remember that Godot does not see all the nodes automatically, so the exact path must be given always.