Edy’s Vehicle Physics – User Guide

User Guide for Edy’s Vehicle Physics 5

A brief description of the package to help you to get started quickly.

Example scenes provided with the package:

  • “The City – Simple Scene”: most simple setup with a single vehicle and the camera.
  • “The City – Vehicle Manager”: using the Vehicle Manager component for controlling several vehicles.

Keys:

WSAD or arrows Throttle, brake, steering
Space Handbrake
Enter Reset vehicle (e.g. if it rolls over)
C Change camera
Tab or Page Up / Page Down Select vehicle (Vehicle Manager scene)
E Makes the gray stone to “jump”. Useful for load tests.
R Repair vehicle damage
T Slow time mode
P Pause vehicles. Camera and vehicle selection works while in pause.
Y Show/Hide telemetry. Shift-Y changes telemetry mode.
Esc Reset scene

How to rig a vehicle from scratch


Component overview

Main components:

  • VehicleController: provides vehicle physics
  • VehicleCameraController: attach to a camera for providing all the camera modes
  • VehicleManager: manages several user-controlled vehicles in the scene
  • GroundMaterialManager: easily manages all the ground materials and their properties

Vehicle add-on components:

  • VehicleAudio: provides all audio effects
  • VehicleDamage: vehicle deformation and deterioration of handling
  • VehicleRandomInput: example script on how to implement a simple AI
  • VehicleStandardInput*: reads the standard Unity Input for controlling the vehicle
  • VehicleTelemetry*: UI and gizmos that expose the internal physic values for developers
  • VehicleTireEffects: provides tire marks, smoke, etc using the information from GroundMaterialManager
  • VehicleViewConfig: visual information to be used by VehicleCameraController when targeting the vehicle

* VehicleStandardInput and VehicleTelemetry may be added to the VehicleManager game object instead, so all the managed vehicles use the same input and telemetry settings.

Additional components:

  • TireMarksRenderer: draws the tire marks on a specific ground material
  • TireParticleEmitter: provides particle effects such as smoke and dust on a specific ground material
  • RigidbodyPause: allows the vehicles with this component to be paused and resumed
  • VehicleNitro: applies a sudden impulse or acceleration to the vehicle
  • SceneTools: generic functions such as slow-time mode and application quit on Escape

Vehicle Controller

Wheels

Reference all the vehicle’s WheelCollider components here. Also, define the role(s) for each one (steer, drive, brake, handbrake).

A transform can be provided to be used as visual mesh for the wheel.

Handling & Behavior

These settings define most of the vehicle’s behavior.

Center of Mass (CoM): Position of the center of mass (CoM) for the rigidbody. If it’s omitted then it will be calculated out of the colliders. Combine the height of the CoM with the Anti Roll setting for configuring the vehicle’s reactions to the different accelerations (throttle, brake, steering).

Tire Friction: coefficient of friction of the wheels. 1 is the standard. More for sport vehicles, less for family vehicles, trucks, etc. This value affects the maximum acceleration of the vehicle.

Anti-Roll: controls the sideways banking. With 0 the banking is defined by the height of the CoM. If 1 the vehicle will steer almost flat.

Max Steer Angle: for the steering wheels, in degrees.

Aero Drag: drag force coefficient with speed. Force applied is coefficient * speed^2. Drag reduces the effective maximum speed of the vehicle.

Aero Downforce: force pushing the vehicle down with speed. Force applied is coefficient * speed^2. The downforce applies more load on the wheels, increasing their grip.

Aero App Point Offset: longitudinal distance in meters from the CoM where the aero forces will be applied.

Aerodynamic properties are applied in a point relative to the CoM given by the property AeroAppForceOffset, in meters. If set to 0 then the drag and downforce will be applied at the CoM. A positive value means applying them ahead of the CoM. A negative value means applying the forces behind the CoM. The property AeroDownforce pushes the vehicle down with the speed, giving the wheels more grip. If AeroAppForceOffset is negative, then the rear wheels receive more extra grip than front wheels. This is useful for achieving stability at high speeds. The opposite also applies: if the vehicle can hardly turn at high speed, then you could try setting AeroAppForceOffset to a positive value (eg. 0.5, 1.0).

Motor

Max Speed Forward,
Max Speed Reverse: maximum speed of the vehicle in m/s for each direction. Drive force is decreased with speed according to the Force Curve Shape. Beyond the maximum speed a resistive force is generated.

Max Drive Force: Maximum force in Newtons (N) that is delivered to the wheels at full throttle. Effective maximum force is decreased with speed according to the Force Curve Shape. Final force applied by wheels depend on the Tire Friction and load.

Max Drive Slip: maximum slip in m/s the wheel is allowed to slide over the surface while it’s receiving drive force. When the wheel is sliding the force is deflected to the slide direction, and the wheel loose sideways grip. The more slip allowed, less sideways grip. Traction Control (TC) limits this slip or even removes it.

Drive Force To Max Slip: Excess of throttle force in N that makes the wheel to slip at Max Drive Slip rate.

Force and slip example:
maxDriveForce is 3000N;
driveForceToMaxSlip is 1000N;
maxDriveSlip is 5 m/s;
The actual tire force at the wheel (load * tireFriction) is 2500N. Applying full throttle means an excess of 3000-2500 = 500N. This is the half of driveForceToMaxSlip, so the wheel is allowed to slip the half of maxDriveSlip, that is, 2.5 m/s.

Force Curve Shape: How the force is decreased with speed. Affects the time the vehicle needs for reaching its maximum speed. Realistic forces have values < 0.5. Arcade-style forces use values > 0.5.

Brakes

Max Brake Force: Maximum force in Newtons (N) that is delivered to the brakes at full brake input. Final brake force applied by the wheels depend on the Tire Friction and load.

Brake Force To Max Slip: Excess of force in N that makes the wheel to slip while braking at its maximum allowed rate (defined below) when receiving brake force.

Brake Mode,
Hand Brake Mode: how the excess of brake force will be translated into slip.

  • Slip: a maximum slip in m/s is allowed when braking. Example: if maxBrakeSlip is 2 the wheel won’t slide further than 2 m/s, even applying a huge brake force. This setting allows controlling the reaction of the brakes when braking at any speed.
  • Ratio: the maximum slip when braking is a ratio of the actual speed. Example: if maxBrakeRatio is 1, appling full brakes will actually lock the wheel. This is a more realistic setting.

Max Brake Slip,
Max Handbrake Slip:
 maximum slip in m/s allowed in the Slip brake mode.

Max Brake Ratio,
Max Handbrake Ratio:
maximum slip ratio in % (0-1) of the actual speed allowed in the Ratio brake mode.

Driving Aids

Each driving aid can be configured gradually from disabled to fully engaged.

TC: Do not allow wheels to slide when applying throttle.

ABS: Do not allow wheels to slide when applying brakes.

ESP: Limits the steering angle with speed.

Vehicle Controls

Just the exposed controls of the vehicle’s user input. Useful in some circumstances while developing in the Editor. Most of time these will be controlled by the component Vehicle Standard Input.

Visual wheels

Settings affecting the visual meshes of the wheels. Can be configured for visual quality or performance:

Spin Update Rate: when to update the wheel’s rotation. OnUpdate provides great quality even in slow motion, OnFixedUpdate is slightly faster.

WheelPositionMode: how to calculate the visual wheel contacting the ground. Accurate uses an additional RayCast on each frame. Fast takes the position reported by the physics directly.

Optimization

Disallow Runtime Changes: Performance optimization if these WheelCollider parameters are not expected to change at runtime: spring, damper, suspension distance, force application point).


Wheel Collider

These properties must be configured in the WheelCollider:

  • Radius (m)
  • Suspension Distance (m)
  • Spring (N/m)
  • Damper (Ns/m)

Position and Radius can be automatically configured to their corresponding visual meshes. Set the Wheels properties in Vehicle Controller (Wheel Collider + Wheel Transform), then click the context menu for the component and select Adjust WheelColliders to their meshes. Check out the video at the top of the page.

These properties may be configured optionally:

  • Force App Point Distance (m) (not important)
  • Center (optional)

All other properties are either not used or handled internally by Edy’s Vehicle Physics 5. No need to set them in the editor, as their values don’t have any effect in the simulation.