Hello Unity Community,

Besides writing my own collision detection or using the OnTriggerEnter/Stay/Exit or OnCollisionEnter/Stay/Exit is there another method to determine if a BoxCollider has a part of another BoxCollider inside it touching it?

-Ethan

And the answer is yes! You can use the BoxCollider.bounds.intersect method.

something like this:

```
if(topHeaderBoxCollider.bounds.Intersects(currentHeader.boxCollider.bounds))
```

I’m using the OnTriggerStay() method with the bounds.Contain() method to check this:

```
void OnTriggerStay (Collider other)
{
if (other.bounds.Contains(myCollider.bounds.min)
&& other.bounds.Contains(myCollider.bounds.max))
{
// Inside the box collider
}
}
```

Hi! I know this topic is very old, but I would like to know what you guys think about this

You can try to write your own function, using the vertices of you cube

```
void CheckBoxIntersection(GameObject go){
//Get the mesh you want to check
Mesh mesh = go.GetComponent<MeshFilter>().mesh;
Vector3[] vertices = mesh.vertices;
int i = 0;
while (i < vertices.Length) {
//Raycast from the middle to each vertex
Ray ray = new Ray(go.transform.position, transform.TransformPoint(vertices*)*
```

*RaycastHit hit;*

*if (Physics.Raycast(ray, out hit, 100))*

*Debug.Log("Intersecting " + hit.collider.name);*

*}*

*}*

*Or if you want to go more precise, you could raycast three times per vertex, racasting from each vertex to the adjacent ones, or something like that, I haven’t actually try this, I am just trying to brainstorm with you guys.*

*Any thoughts about this would be nice*

In addition to the comment above by @UnkPluks, a slight amendment would be:

```
for (int i = 0; i < vertices.Length; i++)
{
//Raycast from the middle to each vertex
Ray ray = new Ray(go.transform.position, transform.TransformPoint(vertices*));*
```

*RaycastHit hit;*

*if (Physics.Raycast(ray, out hit, 100))*

*print("Intersecting " + hit.collider.name);*

*}*

*otherwise you have an infinite loop going on because nothing is decreasing i, which causes a crash.*