0 votes

Making first platformer and wanna add my picked up coin signal from coin scene to another scene(lvl1).But i dont wanna make 150 signals inside lvl1 script , just wanna add 1 signal from coin scene to lvl1 scene but i dont know how to do this.Thanks for helping

in Engine by (16 points)

1 Answer

0 votes

First get a reference to that node which depends on how your nodes are added to the Scenetree

Coin Node.gd

extends Node

signal picked_up

func _enter_tree():
    var lvl1_scene = get_node("path/to/lvl1 scene")
    connect("picked_up", lvl1_scene, "_on_coin_pickup", self)


func _on_coin_pickup(coin):
    print(coin.name) #do something with coin

The example above does not emit the signal which you'll probably want to do on some condition met

by (4,982 points)
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 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 webmaster@godotengine.org with your username.