Alex RED Alex RED - 1 year ago 213
C# Question

Unity check if 2D objects in an array collide without OnCollisionEnter

I have Rigidbody2D and 2D colliders attached to my GameObjects. Is there a way to check if there is a collision between any two of my objects? I found a way: method OnCollisionEnter(), but I want to check for collision in a specific time between specific objects, but not between all. Is there a way to do that? Thanks in advance!

Answer Source

You could create a array stores links to objects collided with this object, and then just add links in OnCollisionEnter and remove links in OnCollisionExit. So you will be able to check if one object's array contain link to the second, if it is - theese two objects are collided in this moment.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download