Alex RED Alex RED - 5 months ago 39
C# Question

Unity check if 2d objects collide

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 OnCollisionEntered(), 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!


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.