Cloned nodes do not emit signals, how to fix

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

I have made clones of Mobs in my game, if they are touched by the player they are supposed to emit a signal, the original node emits the signal fine but the clones made from the initial mob node do not seem to emit this signal, why is that and how can I fix it

do they all use the same variable?

Sinowa-Programming | 2020-06-18 18:03

So basically, I have a mob node and I am cloning this node, so that I can have multiple Mobs in one scene. The clones have the exact same variables and properties as the Mob node that they are being cloned from so yes they do have the same variables. The mob node emits a signal when it is hit, the clones of the mob node don’t emit the signal.

Jaiden | 2020-06-18 18:54

I assume this signal is some custom signal you emit in code? In that case, you should post some code here.

fractile | 2020-06-19 06:41

:bust_in_silhouette: Reply From: dustin

I think signals aren’t the best way to do what you want to do.

A better way of implementing that is instead of using signals , make a variable named whatever node you need to modify (“some_node”) and export is as NODEPATH, something like this : export(NODEPATH) var varname, so that you can just select whatever node you want from the mobs node inspector.

Then, once you do that, you check if its colliding with the player, then do the modifications or call a function to the node you set in the mobs inspector. make sure to use get_node("some_node").variable/function.

I hope this helps you!

Hi thanks so much for your input. I ended up using singletons in the end.

Jaiden | 2020-06-19 14:05

Glad you got your problems fixed!

dustin | 2020-06-20 15:57