How to run method if any collision event anywhere occurs?
Is there any way to have a kind of "global" OnCollisionEnter() or OnCollisionExit() for all objects? I have a lot of simulation data that needs to be evaluated and maintained periodically, but I've discovered that it only has to be done when things collide, and not any other time. Currently I've got my Maintenance() method being called in a GameManager Update(), but would rather just have it run when collisions occur.
Obviously I could run Maintenance() in each and every OnCollisionEnter() or OnCollisionExit(), but this seems tedious and prone to human error.
Any suggestions?
Answer by tormentoarmagedoom · May 22, 2018 at 10:09 PM
Good day.
then you only need that all Oncollision methods send a order to execute the Maintenance() method.
And by other side, you can do a simple timer to execute the same method every X seconds ( if on collisions, but you still need to calculate)
Bye!
Your answer
![](https://koobas.hobune.stream/wayback/20220612163211im_/https://answers.unity.com/themes/thub/images/avi.jpg)