i have a very weired problem with a car. it is a simple model consisting of a few objects for the body, via script there are 4 wheelcolliders attached and 2 box colliders are used for the body.
everything is centered, center of mass is set to 0/0/0
as soon as the car hits the ground, it stands hard to the right, as the center of mass would have been switched hard to the back right, but outputting it says it is still 0/0/0:
if i then, while keeping the game running, in the editor, take either the rigid body or any of the box colliders, just klick on any center value and press return, the situation is fixed:
i tried to just set center via script in Update, but this does not help.
what could cause this trouble, and can i somehow ‘rebuild’ a editor change event scriptwise as a workaround?
i tried to rebuild the whole car, this time replaceing the multi object body by a single cube… and… it does not happen then, with the same script, the same wheel objects
i then reduced the multi object body to a single mesh… and… it happens again
is there any reason, why a mesh could cause some balance problems with the physics engine, although the mesh seems to be centered?
no mesh colliders, the last attempt only has one object for the body (no colliders at all), two objects for the wheels (one back, one front, duplicated to the other side) and a script generated wheelcollider per wheel
still offcentered, if i recreate everything replacing the body object by a box, it is centered again, so the problem must be with the body mesh, although i don’t see any problem
arr, just noticed one thing reading my own text: i did not just replace the body with a box, i also replaced the wheel objects whith spheres, so i tried to keep the body model and replace the wheel objects by sphere… and well… it is centered then, so the problem is in the wheels, not the body, still i see no reason why this should happen, at least a new direction to investigate
ok, wheels as sphere is no solution too, as i forgot, that sphere by default gets a sphere collider attached, which prevents the wheel collider to work.
i have striped everything down to bare minimum, please, if anybody could have a look at the following file: