hi
i have a .cs script, on an empty gameobject,
but I need to activate / run it … every time an enemy dies.
any idea please …?
hi
i have a .cs script, on an empty gameobject,
but I need to activate / run it … every time an enemy dies.
any idea please …?
an empty gameobect isn’t “inactive”… unless you are purposely setting it to that (terminology matters here since code will not run at all on an inactive gameobject).
Assuming your gameobject is active, you just want the script to react to something happening elsewhere in your game, I’d suggest you look up “unity event”.
https://unity3d.com/learn/tutorials/modules/intermediate/scripting/events
thanks a lot
i put the script on an inactive gameobject…
then set active the gameobject and follow the script will rund, then set inactive again…
and repeat … and repeat…
but this is not the profesional way…
thanks a lot so much again for your / any help.
i will try what you say.
Code can still be run on inactive components. Inactive components just will not call unity functions, Start(), Update(), FixedUpdate(), OnTriggerEnter(), ect. ect. ect.
If I have a component cached in a variable that belongs to an inactive component, I can still call functions on it.