Car Mass Problem - Problem with Rigidbody Mass-Shape in Unity

I just started with Unity, and I’m creating my car prefab for my game.

The biggest problem that I have is the mass model is too massive. Notice in the picture my car uses spheres to collide and they are pretty large, but I want the mass properties of the rigidbody to be much smaller- like a small cube or point in the center of the prefab.

You get it right?

So my car body weighs 1440 kg (is that right? unity uses “kg” as weight measurement?)

The car’s tendency to roll is messed up because the mass and rotational inertia is defined by the spheres. I need to readjust to a smaller mass-shape in order to get the right rotational inertia.

If anyone cold help me with this, I would really appreciate it.

  • Rush3Fan

The overall mass of the car is noted in the mass variable on the rigidbody. This rigidbody generally should be placed on the root object. (it does not have to be, but it is good practice)

Now, you say that your vehicle is 1440. (kg is fine as long as your keep all of your mass to size ratios the same) This means that when the game starts and you have added all the colliders it generates the “centerOfMass” and assigns it to the vehicle. This includes all the weights for all of the colliders (including the wheel colliders) and gets the centerOfMass. You can then adjust the centerOfMass through script. Simply say “rigidbody.centerOfMass += Vector3(0, -0.5, 1);” or something like that. That redefinition adjusts the centerOfMass to an offset from where it is.

Now, because your middle spheres are so large, it offsets the centerOfMass to someplace way too high. Deviating it to adjust for it will then yield poor results. Ideally, your spheres or whatever collider set you want to use should match the volume without overlaps. So to fix your problem, create a closer collision structure, either by adding more spheres (remember not to overlap them) and/or cubes, mesh colliders or whatever fits your space better.

Yep, I put the rigidbody part at the root object.

Yes, I have a thing in the script that sets the center of mass already.

The mass shape = the sphere colliders just as you were explaining… that’s the problem.

I could make a small cube as my car body and the mass would be perfect, but the car wouldn’t collide correctly.

What I need is to separate the two issues: 1.)the mass model and 2.)the collider model - They should be different in shape.

This is possible in other game engines that use PhysX, so I don’t understand why Unity can’t do this. :confused:

Both are related. As far as I know you can’t seperate them. Judging from your image, the colliders are way to big. You can either make more spheres (smaller) to better define the structure or use a MeshCollider to get the exact shape. You can also use both a mesh and sphere colliders to get better physics reaction.

Now, after thinking about it, I took a car model and shoved soem spheres on it, and it flipped and rolled better. There spheres were within the shape though. The mesh collider was very blocky so when it rolled it had a blocky feel.

With some changes, there can be advantages. First, only use spheres that are about 0.2 in radius. Fill only the skin of the vehicle with them. Make sure that you fill the bottom too. Now, your car should roll better, but have about 30+ spheres as a collider. next, when the vehicle impacts something, you can reposition the spheres as well as deform the mesh in that area to achieve a damage table. This would mean that when you hit a pole, your vehicle wraps around the pole and the remaining collider sub structure would maintain that shape. All you would have to do is redo the centerOfMass every time that the colliders are reorientated.

With enough velocity and force, you could bend the entire vehicle (wheels and all) to make an incredible change in how the vehicle operates. You could also create sensor’s for damage on critical parts like engine or fuel tanks and such.

Aww man… that’s too bad. If I can’t get the right mass settings, then I will have to redesign the car driving physics. I’m actually trying to port from another game engine.

Yes, compared to the placeholder geometry, those sphere’s do look big, but they are made to fit some nicer looking car bodies later on.

Thanks for the help BigMisterB… Not exactly what I was wanting to hear, but it gives me the answer.

  • Rush3Fan