Can I detect a collision between two triggers on other objects
I am making a 2d platformer game. What I want to do is to start moving my enemies when the player is within a certain distance from the enemy. I used to solve this problem by calculating the distance between each enemy and the player in the Update() function. Now I realise how unoptimised that approach is and I am trying to figure out a better way to acheive the same result. What I have come up with is a trigger based approach where I would start moving an enemy when the player collides with the trigger.
I know I can attach a script with the build in OnTriggerEnter2D() function to the trigger object and detect the collision. However what I want to know is:
Is it possible to detect a collision between two triggers from a class that is not attached to either one of the objects with the collider components? Like a OnTriggerEnter2D() with two Collider2D's and then look for the collision of those.
Answer by doublemax · Sep 01, 2016 at 07:08 PM
You mean an on-demand check if two objects collide? Unfortunately not possible at the moment, it's a requested feature though: https://feedback.unity3d.com/suggestions/expose-methods-for-manual-collision-checking