Unity3d: Box collider attached to animated FBX models through scripts at run-time have wrong dimension

Posted by Heisenbug on Game Development See other posts from Game Development or by Heisenbug
Published on 2012-10-19T13:23:27Z Indexed on 2012/10/19 17:20 UTC
Read the original article Hit count: 348

I have several scripts attached to static and non static models of my scene. All models are instantiated at run-time (and must be instantiated at run-time because I'm procedural building the scene).

I'd like to add a BoxCollider or SphereCollider to my FBX models at runtime.

With non animated models it works simply requiring BoxCollider component from the script attached to my GameObject. BoxCollider is created of the right dimension. Something like:

[RequireComponent(typeof(BoxCollider))]
public class AScript: MonoBehavior
{

}

If I do the same thing with animated models, BoxCollider are created of the wrong dimension. For example if attach the script above to penelopeFBX model of the standard asset, BoxCollider is created smaller than the mesh itself.

How can I solve this?

© Game Development or respective owner

Related posts about unity

Related posts about bounding-boxes