- Home /
Asset bundle object center differs to prefab's object center.
Hi all, I am building asset bundles from prefabs within my project. In the image here:
The left object with the object center on the far back middle of the object is an asset bundle that has been instantiated in the scene. The right object is the prefab that the asset bundle was created from using an editor script (the script is from the AssetBundle API sample project on the Unity website). I've ensured that the mesh and prefab has nothing strange going on with the object center. However it differs as you can see, does anyone know why this may be and how to resolve this disparity?
Many thanks.
Answer by N1nja · Jul 11, 2010 at 04:36 AM
Why does it look like the Object on the left is just several GameObjects that were all selected at once? Is that what an asset bundle is? ( I've never played around with it.. )
It appears though, that is actually the centroid.. on the left..
Centroid is calculated as:
Vector3 centroid = Vector3.zero;
for(int i = 0; i < vertices.length; ++i)
{
centroid += vertices[i];
}
centroid /= vertices.length;
considering in your asset bundle the majority of the vertices are on the left/middle of the collection, the centroid should naturally be near that region.. perhaps you're just expecting the boudning box center, rather then the centroid?
I'm not sure that is.. how unity calculates the center.. :P Just a guess
Answer by Mike 3 · Jul 04, 2010 at 10:06 AM
The easiest way I can think to resolve it is to add an empty gameobject as parent at the pivot point you want, then send a bug report about this
Well actually the meshes themselves are children, the parent is an empty GO already. :<