OnCollisionEnter for other object?

Hello Everyone,
I have a some objects and i am creating instantiates of these objets . I have one brick and i am creating instantiates of this brick and i want to check OnCollisionEnter only for brick or i want to add this script on empty gameobject but if i add OnCollisionEnter Script on Empty Gameobject then i can not find the OnCollisionEnter on brick,
Is it any way to detect OnCollisionEnter for brick and my script will be attached on any other object ? not via tag?

I think you’re trying to do something when a Brick collides with something?
There are two ways to do this:

  1. Add OnCollisionEnter to a script attached to the Brick object. This will give you a Collision object that contains a reference to the collider of the object the Brick has hit.

  2. Add OnCollisionEnter to a script attached to the object Brick will collide with. The Collision object will contain a reference to the Brick’s collider and gameObject.

As far as I’m aware, it’s impossible to detect the collision of an object from a script not attached to either object. Perhaps if you explained why you’d want to do that we could come up with a better solution?

Actually No there is another way. If it is a simple shape you can check the Collision with Physics.CheckBox, Physics.CheckCapsule or Physics.CheckSphere and all you need is the positions of the objects which you can do with an array and a foreach loop to loop through the array.