Game Development Reference
In-Depth Information
The second component we have to add to the root object of our vehicle is a rigid body. For
out vehicle we need a reasonable mass such as 1500 kilograms. Additionally, we need to
set the drag to a relatively high value, in order to give the feel of a heavy object that needs
great force to move and stop after short time when there is no force to move it. Therefore,
we need a value such as 0.25 for the drag, and a value of 0.75 for the angular drag. By de-
fault, Unity sets the center of mass of an object at the origin of the local space of the object.
However, sometimes we need to have a different center of mass. In case of our vehicle, we
need to set the center of mass a bit lower, in order to prevent the vehicle from flipping easily
when it turns right or left. To perform that, add an empty game object as a child to the game
object of the vehicle, name it CenterOfMass , and position it at (0, -0.5, 0.2). We are going to
specify this position as the center of the mass of our vehicle later on using a script.
Now we need to have realistic wheels for our vehicle. These wheels are going to be the core
element in the simulation, since they are responsible for applying motor torque, braking,
steering, and spring suspension. A unique property of Unity, which does not necessarily
apply to other game engines, is the separation between the physical wheel collider compon-
ent and the visual wheel object. Therefore, we are going to add an empty object for each
wheel collider, instead of adding these collider directly to the wheels we have made.
Search WWH ::




Custom Search