# My car is being sporadic...

I had a nice setup with my car working nicely and all,and I saved it and came back and now if the mass of the rigid body is set to more then 100 it starts freakin out with the ground in a way I’m sure you’ve all experienced. It is pulled into the terrain and is spun around and flung back up into the air. It does the same on a cube or other non-thin object. I am also getting the error:

Actor::updateMassFromShapes: Compute
mesh inertia tensor failed for one of
the actor’s mesh shapes! Please change
mesh geometry or supply a tensor
manually!

This might not have anything to do with it, but my car hierarchy is this

Car Assembly (empty object, rigidbody, AND BOX COLLIDER so it should cancel the error)

• Car model (made of many, many meshes because I used sketchup-bender-unity)
• Four wheel models
• Four wheel colliders

And my script is this, if you really want to read through it.

``````var rearWheel1 : WheelCollider;
var rearWheel2 : WheelCollider;
var frontWheel1 : WheelCollider;
var frontWheel2 : WheelCollider;

var wheelFL : Transform;
var wheelFR : Transform;
var wheelRL : Transform;
var wheelRR : Transform;

var steer_max = 20;
var motor_max = 40;
var brake_max = 100;
var steerSpeed = 50;
var centerofgravity = -0.5;

var steer = 0;
var forward = 0;
var back = 0;
var brakeRelease = false;
var motor = 0;
var brake = 0;
var reverse = false;
var speed = 0;

function Start() {
rigidbody.centerOfMass = Vector3(0, centerofgravity, 0);
}

function FixedUpdate () {

speed = rigidbody.velocity.sqrMagnitude;
steer = Mathf.Clamp(Input.GetAxis("Horizontal"),
``````

-1, 1);
forward = Mathf.Clamp(Input.GetAxis(“Vertical”),
0, 1);
back = -1 * Mathf.Clamp(Input.GetAxis(“Vertical”),
-1, 0);

``````if(speed == 0) {
if(back > 0) { reverse = true; }
if(forward > 0) { reverse = false; }
}

if(reverse) {
motor = -1 * back;
brake = forward;
} else {
motor = forward;
brake = back;
}

rearWheel1.motorTorque = motor_max * motor;
rearWheel2.motorTorque = motor_max * motor;
rearWheel1.brakeTorque = brake_max * brake;
rearWheel2.brakeTorque = brake_max * brake;

if ( steer == 0 && frontWheel1.steerAngle != 0)
{
if (Mathf.Abs(frontWheel1.steerAngle) <=
``````

(steerSpeed * Time.deltaTime))
{
frontWheel1.steerAngle = 0;
}
else if (frontWheel1.steerAngle > 0)
{
frontWheel1.steerAngle = frontWheel1.steerAngle - (steerSpeed *
Time.deltaTime);
}
else
{
frontWheel1.steerAngle = frontWheel1.steerAngle + (steerSpeed *
Time.deltaTime);
}
}

``````else
{
frontWheel1.steerAngle = frontWheel1.steerAngle + (steer *
``````

steerSpeed * Time.deltaTime);
if (frontWheel1.steerAngle > steer_max) { frontWheel1.steerAngle =
steer_max; }
if (frontWheel1.steerAngle < -1 * steer_max) { frontWheel1.steerAngle =
-1 * steer_max; }
}

``````frontWheel2.steerAngle = frontWheel1.steerAngle;
wheelFL.localEulerAngles.y = frontWheel1.steerAngle;
wheelFR.localEulerAngles.y = frontWheel2.steerAngle;

//wheelFR.Rotate(frontWheel1.rpm * -6 * Time.deltaTime,0,0);
//wheelFL.Rotate(frontWheel2.rpm * -6 * Time.deltaTime,0,0);
//wheelRR.Rotate(rearWheel1.rpm * -6 * Time.deltaTime,0,0);
//wheelRL.Rotate(rearWheel2.rpm * -6 * Time.deltaTime,0,0);

wheelFR.Rotate(0,0,frontWheel1.rpm * -6 * Time.deltaTime);
wheelFL.Rotate(0,0,frontWheel1.rpm * -6 * Time.deltaTime);
wheelRR.Rotate(0,0,rearWheel1.rpm * -6 * Time.deltaTime);
wheelRL.Rotate(0,0,rearWheel2.rpm * -6 * Time.deltaTime);

}
``````

its probably colliding with itself.
Check if you have multiple rigidbodies and colliders on the car intersecting with themselves.

For example did you add seperate objects for doors or wings… that each have physics setup ? if so you might want to disable them until after a crash. I had the same problem you are describing, and it was due to multiple colliding parts, colliding with each other, yet were parented to the car, so they couldn’t move how the physics wanted to move/collide them.
now I hvae 1 ‘active’ rigidbody, 3 box colliders, 4 wheels.

I dont think the mass is an issue, I use 500 to 1000 on my car masses

its also possible something weird happenned on save. try reimporting the car, or re-loading unity.