Auto Bouding Box - Level Creation

Hi Guys,

I’m a newbie.

Is there any feature like in UDK, where boudingboxes are automatically created based on naming convention for imported meshes?

If not I’d love this feature!

Btw, How do you guys generally add collisions for imported levels? From what I’ve learnt, either use mesh-collider or add the boxes manually. Is thr any other way?

Thanks,
Vik

Hay that’s a good idea!.. If I understood that you want box colliders to have auto creation based on the bounds of a mesh. If that is the case I made a quick script that you can place in the object that has the mesh filter. Don’t know if I miss typed anything as it’s hand coded on the spot, but hope it works for you.

function Start(){
     if(!transform.GetComponent(BoxCollider)) gameObject.AddComponent("BoxCollider");
     transform.GetComponent(BoxCollider).center = transform.GetComponent(MeshFilter).mesh.bounds.center;
     transform.GetComponent(BoxCollider).size = transform.GetComponent(MeshFilter).mesh.bounds.size;
}

Personally I think this would make a good little feature for unity. Just a little “mesh bounds” button in the collider/s component/s would work.

Hi King,

Thanks for the reply.

What I meant was -
Suppose I rig a whole level in some editor. Lets say it consists of buildings, chairs, etc.
After importing this, I need to find each chair and building and attach your script (or add this component manually).

In UDK for ex, I can create a box around each chair building while creating it. But use a name like BOX_
When imported, everything BOX_ will be removed and replaced by a BoundingBox equivalent.

So wanted to know if this exists Unity?

Thanks,
Vik