# Most efficient way to get the world position of the 8 vertices of a Box Collider

What I am looking for is the most efficient way to get the world position of the 8 vertices of the Box Collider of a freely rotated Game Object. I cannot use collider.bounds since object is rotated, not axis-aligned.

I'm using Unity 5 with C#.

• Typically you make a matrix out of all the matrices that transform the game object (hierarchically), and you multiply the vertex by that matrix... Your question is quite vague. Oct 15, 2015 at 4:19
• Thanks for your comment. I will try to figure out what you've said... As for my question, I don't get why it is that vague: I thought it was a very specific question to ask how to find out the world position of the 8 external vertexes of a Box Collider (my mention to a rotated Gameobject was only to prevent from receiving suggestions of using collider.bounds) Oct 15, 2015 at 13:33
• Given the tags and the text, it's hard to understand you use a framework; we only know you use c# and have a box collider, without actually knowing your implementation. Are you using Unity? This would be a very important tag to add to your question. Although this Q&A site welcomes a lot of Unity questions (and answers), this is not a Unity only stack (Unity or any other framework), so we can't assume anything about the base technology you use. This is why I said your question is vague. You should edit your question (and tags) to give a bit more details, I'm sure you'll get better answers :) Oct 15, 2015 at 14:05
• Oh, now I see what you mean. Sorry for not providing such information beforehand. I thought that for this question there would be no difference between frameworks, provided that they employ C# and PhysX. But even though, I did not mention PhysX either. So I will edit it! Many thanks for your feedback Oct 15, 2015 at 14:21

Try this:

    BoxCollider b = obj.GetComponent<BoxCollider>(); //retrieves the Box Collider of the GameObject called obj

Vector3 vertice1 = myobject.transform.TransformPoint(b.center + new Vector3(-b.size.x, -b.size.y, -b.size.z)*0.5f);
Vector3 vertice2 = myobject.transform.TransformPoint(b.center + new Vector3(b.size.x, -b.size.y, -b.size.z)*0.5f);
Vector3 vertice3 = myobject.transform.TransformPoint(b.center + new Vector3(b.size.x, -b.size.y, b.size.z)*0.5f);
Vector3 vertice4 = myobject.transform.TransformPoint(b.center + new Vector3(-b.size.x, -b.size.y, b.size.z)*0.5f);
Vector3 vertice5 = myobject.transform.TransformPoint(b.center + new Vector3(-b.size.x, b.size.y, -b.size.z)*0.5f);
Vector3 vertice6 = myobject.transform.TransformPoint(b.center + new Vector3(b.size.x, b.size.y, -b.size.z)*0.5f);
Vector3 vertice7 = myobject.transform.TransformPoint(b.center + new Vector3(b.size.x, b.size.y, b.size.z)*0.5f);
Vector3 vertice8 = myobject.transform.TransformPoint(b.center + new Vector3(-b.size.x, b.size.y, b.size.z)*0.5f);

• I know this is late, but that looks very repetitive, I'd suggest moving it into an array. Jul 13, 2017 at 0:03
• Can someone improve this answer explaining how this accounts for any rotation of the box? I don't see any orientation information being accounted for here. I'm guessing "size" on the collider has directional context since it's a Vector3, but confirmation from someone with more experience in Unity would be reassuring. Feb 8, 2019 at 22:52
• @ScottLin the TransformPoint function applies the orientation, translation, and scale of the object's transform (and its parent transforms) to the input point. Mar 21 at 21:22

If you can access a Mesh of the same size and shape, you can use Mesh.bounds, which returns positions in local space.

public static List<Vector3> GetBoxColliderCornersWorld(BoxCollider boxCollider)
{
Vector3 size = boxCollider.size;
List<Vector3> list = new();
var signs = new List<int> { -1, 1 };
signs.ForEach(signX =>
signs.ForEach(signY =>
signs.ForEach(signZ => {
var vector = new Vector3(size.x * signX, size.y * signY, size.z * signZ);