i have a script that is attached to my prefab.there is nearly 20 objects are created . for each them the script is same.
i need to disable the script when the collision occurs according to the relative object .
am using
this.enabled=false;
it does what i need . am also checked in hierarchy .the script is disabled.
even though the script is the function in the script still running.
what i do.
i couldn’t destroy the script why i need to use it later.
Disabling a script causes Update, FixedUpdate, LateUpdate, Start, and other time-based methods to stop running. OnTriggerEnter/Exit/Stay and OnCollisionEnter/Exit/Stay will still get called, as well as Awake (if you instantiate the object with the script disabled).
The easiest thing to do would be to check if the script is enabled in the spots where it’s doing things it shouldn’t: