Envio de señales entre nodos hermanos

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By aljuarismi

Hola es posible que un emisor envie una señal a un hermano?
Como hago referencia a un nodo hermano ya instanciado para indicarle que ejecute su metodo mediante connect?

var pelota=load(“res://pelota-Football/pelota.tscn”)

connect(“patear”,pelota,“aumentar_velocidad”)

Me da el siguiente error:
E 0:00:12.341 emit_signal: Error calling method from signal ‘patear’: ‘PackedScene::aumentar_velocidad’: Method not found…
<Fuente C++> core/object.cpp:1257 @ emit_signal()
jugador.gd:25 @ _input()

¿porque busca el metodo en PackedScene?

Gracias!

:bust_in_silhouette: Reply From: wyattb

I think what you need is:

pelota.connect ("patear", self, "aumentar_velocidad")

because the signal is emmited from pelota. And you need a function in your current script

func aumentar_velocidad():

The signal is emmited from jugador :

emit_signal(“patear”)

jugador is nodo brother

aljuarismi | 2021-06-21 17:09

Where is func aumentar_velocidad

wyattb | 2021-06-21 17:34

The function aumentar_velocidad is on the pelota.
I solved it by creating a main node, pelota parent and jugador and connecting them as follows in main.gd:

func _ready():
#conecto señales entre nodos
$“RigidBody mundo/jugador”.connect(“patear”,$“RigidBody mundo/pelota”,“aumentar_velocidad”)

aljuarismi | 2021-06-21 17:42