Hi everyone, I have a script that uses the OnTriggerEnter function.I have the script attached to a cube and set for Is Trigger.But for some reason the collider isn’t working properly and objects pass right through it. Any idea what is up?
Hello. Is Trigger in unity disables the function of the collider and turns it into a passable trigger. (When you think about it, how would OnTriggerEnter / OnTriggerExit work if it didn’t allow you to pass through the collider?)
The best way to do the Is Trigger on an object is to add another collider component to the GameObject that you want to be an event trigger. So in other words, the object itself will still have the collider that stops the player, and the Is Trigger collider component will act as the trigger for your GameObject. Make sure that you have the Trigger Collider a little larger than the GameObject itself. Hope this helps.
If you set it as a trigger, then it will no longer do collisions. It will only trigger the trigger events (enter, stay, leave)
This is meant to be like this as you use triggers for cases where you want to detect presence of objects in an area. if you want a physical reaction, then do not mark the object as a trigger but leave it as a collider and it will work just fine.