Question by
The_annoying_guy · May 11, 2017 at 08:42 PM ·
c#unity 5vroptimizationinfinite runner
if collider != trigger //do stuff
Backstory. I have a lot of mesh colliders, because of this I only want them to be activated when I'm in the same "Area" as the objects. To solve this I have placed a trigger collider, that activates the colliders of its children when triggered, and deactivates them on exit. The problem i ran into was that it also deactivated itself, meaning that the next time I entered the "Area" there where no collisions. Id like to do something in the lines of:
if (collider != trigger) { Collider.enable = false; }
Thank you in advance, this is my first question here but will certainly not be the last.
Comment
Best Answer
Answer by Matthewj866 · May 11, 2017 at 10:14 PM
if (!collider.isTrigger)
{
collider.enable = false;
}
based on your description this should solve your problem.