0
\$\begingroup\$

Ok so i wanted to ask a basic question. suppose i have an edge collider 2d,

Fact - if i add the OnTriggerEnter() into my code. it will check for trigger enters constantly.

Now, If the edge collider exists but i don't put OnTriggerEnter(), will the game still check for trigger enter collisions? or will it not check for them?

\$\endgroup\$
1
\$\begingroup\$

The physics system is always checking for collisions. OnTriggerEnter is there to receive events when a collision does happen, and that collision involves a trigger. If you're attempting to optimize, you should remove the collider. Removing the endpoint for the events is an optimization, but that's mostly from not having to run the code contained in the OnTriggerEnter event handler.

In other words, Unity's checking for collisions will not increase or decrease based on OnTriggerEnter.

\$\endgroup\$
2
  • \$\begingroup\$ thanks! Just one more thing, is it better to use an edge collider or using 5 raycasts everytime i want to check for collision? \$\endgroup\$ – Tanmay Arora Feb 21 '18 at 3:47
  • \$\begingroup\$ A collider will be more efficient \$\endgroup\$ – MichaelHouse Feb 21 '18 at 11:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.