Vehicle Implementation

Any type of vehicle that has 3 or more wheels can be used inside the Mobile Traffic System. Here is how you can set up your vehicles:

Wheel pivots

A vehicle wheel needs a special hierarchy to work properly, and the wheel pivots should be placed in the following way for the wheel to work properly.

The first pivot should be on the ground as shown here:

The Y position for this pivot should be 0. This game object is used to rotate the wheel on the Y rotation axis if that wheel is marked as steerable.

The second pivot should be in the center of the wheel. All the coordinates should be 0 except the Y position. The difference between the first pivot and the second pivot represents the wheel radius.

This pivot is used to rotate the

Inside the second pivot, you should place your wheel graphic with the pivot in the center of it.

Vehicle Component

Add VehicleComponent.cs on the root of your vehicle prefab.

This will automatically add a RigidBody to your vehicle.

A vehicle requires at least a box collider to work properly.


Mass - set the mass to a real-life value

Drag - set the drag to a value different than 0.

Angular Drag - set the angular drag to a value different than 0.

Configure car

After the Rigidbody properties are set press the Configure Car button and the references should be assigned automatically.

If some configurations are not correct, you will get an error inside the console explaining what to do to fix it:

Object References

Rb - The Rigidbody of the car

Car Holder - An empty GameObject that is placed at the root of your car and contains all other GameObjects of the vehicle like this:

The car holder is used to automatically set the pivot of the vehicle between the back wheels.

Front Trigger - is a trigger automatically generated when you press Configure Car.

The purpose of the front trigger is to detect obstacles in front of the car.

You can control its length by setting the Trigger Length property on the Vehicle Component.

Shadow Holder - sometimes using real-time lights on traffic vehicles might be CPU expensive, especially on mobile. For that, there is a fake shadow support. Just create a GameObject with a shadow object for the current vehicle and the system will move the object with the vehicle and keep it on the road.

Wheel properties

All Wheels - is a list of all vehicle wheels. If the wheels are named properly, the list will be automatically assigned.

Wheel Transform is the first pivot.

Wheel Graphics is the second pivot.

Wheel Position:

  • Front - will steer.

  • Back - used to calculate the vehicles' rotation point.

  • Other - additional wheels with no importance.

A car should have at least 1 Front and 1 Back wheel.

Wheel Radius - automatically computed from the distance between the first pivot and the second pivot.

Max Suspension - automatically computed as half of the wheel radius.

Max Steer - is the max turn angle allowed for the front wheels in degrees.

Max Suspension - will override the computed value of max suspension if set to a value different than 0.

Spring Stiffness - determines how rigid the suspension will be. The higher the value -> more rigid the suspension.

Car Properties

Vehicle Type - Specifies the type of vehicle. See Vehicle Routes Setupfor more info.

Min Possible Speed & Max Possible Speed - At instantiation, each vehicle will have a maximum speed randomly selected between the min value and the max value. This creates more variation in the traffic.

Acceleration Time - the time it takes for the vehicle to accelerate from a full stop to its maximum speed. The acceleration is linear.

Distance To Stop - the distance at which the vehicle will come to a stop if there is an obstacle or another vehicle in its path.

Trigger Length - is the length of the trigger used to detect obstacles.

Update Trigger - If checked, the trigger length will dynamically adjust based on the current speed of the vehicle.

Max Trigger Length - the maximum length of the trigger at the vehicle's maximum speed.

Trailer Component - required if the current vehicle is a truck capable of towing a trailer. Check Truck + Trailer Implementation

Automatically computed values are calculated based on the vehicle's settings. If they appear incorrect, ensure that colliders and wheel positions/pivots are correctly configured.


Create an empty GameObject called Lights (The name is important if you want the lights to be auto-assigned by the system, otherwise you'll have to manually assign them).

The parent GameObject should contain 6 child objects called:

BlinkersLeft - active when the left blinker is on

BlinkersRight - active when the right blinker is on

FrontLights - front lights are active when car lights are on

RearLights - backlights active when lights are on

ReverseLights - backlights active when the vehicle is going backward

StopLights - active when the vehicle is braking

Each of the above GameObjects can contain any type of object and as many objects are required to construct the lights(projectors, special materials, etc). If a light is on the corresponding GameObject is enabled, and if it is off the GameObject is disabled.

The name of the objects needs to be identical to the above ones for the auto-assign to work. otherwise, you'll have to assign those objects on your own.

In order for the lights to work, the VehicleLightsComponent.cs script needs to be added to the root of your vehicle.

If the names are correct, all references should be automatically assigned for you when pressing the Configure Car button from Vehicle Component, otherwise you'll have to manually assign them.


If you want your traffic cars to have sound, add the EngineSoundComponent.cs on your vehicle. This will automatically create an audio source on your vehicle prefab.

Make sure to add an engine sound inside the AudioClip field to your audio source and configure the 3D sound settings as you see fit.

Sound Component Settings

The sound component uses pitch and volume to modify your loop engine sound to seem like it is a real engine. It has the following customizable parameters.

Min Pitch - is the pitch used when the vehicle is stationary.

Max Pitch - is the pitch used when the vehicle is at max speed.

A linear interpolation between the 2 values is used for the rest of the speeds.

Min volume - is the minimum volume of the audio source when the vehicle is stationary.

Max volume is the maximum volume of the audio source when the vehicle is at maximum speed.

A linear interpolation between the 2 values is used for the rest of the speeds.

If you are not able to hear the sound, make sure your listener is in the range of the audio source

Check this video tutorial for a better understanding. Keep in mind that this video is for an older version of the plugin so some settings might not be available in the newer version.

Last updated