Objective

Main Objective of this post is to give an idea about how to work with wheel collider for motor vehicle in Unity

 

 

Step 1 Unity Wheel Collider

The Unity Wheel Collider for motor vehicle is a special collider of real car tires. It can be used for objects other than wheels, but it is specifically designed for vehicles with wheels. Unity contains powerful 3D physics engine. Unity is easy to use for joints and colliders in 3D solution. So here I am implementing wheel collider for car vehicle with the help of UNITY 3D. The following steps are used for setup to convert static car model into moving car.

 

Step 2 Implementation

 

2.1 Car Model

You must have car model, which have wheels along with body Mesh. 

Wheel collider for motor Vehicle

 

2.2 Import into Scene

Import car model into scene, adjust wheels at proper position, add required collider (Box/Mesh collider) in the model to support just body of car.

 

2.3 Add Wheel Collider

Now select any wheel of car in Hierarchy then go to menu-bar and select Component/Physics/wheel Collider. This will add wheel Collider to selected wheels. Repeat this step for remaining wheels.

 

2.4 Adjust Wheel Collider

Adjust wheel Collider position as per below figure such that it fits the corresponding wheel, to do this adjust Position in Transform and Radius in wheel Collider Component. 

wheel colliders

inspector wheel colliders

 

2.5 Remaining Parameters

Remaining parameters in Wheel Collider Component are discuss below:

Centre Centre of the wheel in object local space.
Suspension Distance Maximum extension distance of wheel suspension, measured in local space. Suspension always extends downwards through the local Y-axis.
Suspension Spring The suspension attempts to reach a Target Position by adding spring and damping forces.
Spring Spring force attempts to reach the Target Position. A larger value makes the suspension reach the Target Position faster.
Damper Controls movement of springs. A larger value makes the Suspension Spring move slower.
Target Position 0 maps to fully extended suspension, and 1 maps to fully compressed suspension.
Mass The Mass of the wheel.
Forward/Sideways Friction Properties of tire friction when the wheel is rolling forward and sideways. Adjust friction properties according to need.

inspector

 

2.6 Create Script

Now create a script to control car if have not already created.

  • Motor Torque, brake torque, steer angle, rpm are some of important variables of wheel collider Component (Refer Scripting Reference for future reference).

I hope you found this blog helpful while working on Wheel Collider for Motor Vehicle in Unity. Let me know if you have any questions or concerns regarding Unity, please put a comment here and we will get back to you ASAP. Got an Idea of Game Development? What are you still waiting for? Contact us now and see the Idea live soon. Our company has been named as one of the best Game Development Company in India.

I am Gamer, Game Programmer, Part-Time Blogger, Voracious Reader.