I need to disable a script along with OnTiggerEnter function contrianed within it? As of now, disabling a script does not Disable OnTriggerEnter functions, which is a problem. Is there a way to disable ONtriggerEnter without disabling the trigger of my Gameobject?
Wrap your OnTriggerEnter body with if(enabled){ }
Yup I ended up making a boolean “OnTriggerEnterAllowed” then disabling it. thanks!
You don’t even have to do that. enabled is part of Behaviour already and is the thing that gets flipped to false when you disable your script. Everything you need is already there ![]()
Not true. All of the physics engine messages gets called on the script, regardless of wheter it’s enabled or not.
That is incredibly bad design on Unity’s side. The UI system has the same problem, where it’s kinda random if a component respects .enabled or not.
The only thing you can trust .enabled to do is to turn off methods with Update in their name.
I know - my point was that he could use that boolean instead of creating a new one.
I agree it’s bad design.