The Godot Q&A is currently undergoing maintenance!

Your ability to ask and answer questions is temporarily disabled. You can browse existing threads in read-only mode.

We are working on bringing this community platform back to its full functionality, stay tuned for updates. | Twitter

+1 vote

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

in Engine by (23 points)

do they all use the same variable?

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.

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

1 Answer

0 votes

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!

by (449 points)

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

Glad you got your problems fixed!

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 Frequently asked questions and 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 [email protected] with your username.