Search Unity

For those who were at Unite ’09, this is the racing game that was demoed when showcasing the new profiler in Unity 2.6 during the keynote. The aim of this tutorial is to show you how to create a racing game with Unity. In it, we assemble a car from a 3d model, scripts and Components. The tutorial provides you with a complete project of a driving game, where you can play with a finished scene and explore how everything is put together. We also provide you with a scene that has everything ready but the car, which you will then work on completing.





Section 1 – Assembling the Car

The first section of the tutorial provides details about assembling a Car Prefab from a 3D model, scripts and components. We discuss the basics required to setup the car, including adding collision, shadow settings for the car and skid marks. Upon completing this part of the tutorial, you should have a working knowledge of the Scene and a fully functional driving demo.



Section 2 – Tweaking the Car


“Tweaking the Car”, discusses various aspects of the car’s configuration. In this section, you will learn how to tweak the car to behave “better” or in different ways. The goal of this section is to provide a more thorough understanding of the car setup to allow for customization.



Section 3 – Under the Hood


For those adventurous souls looking to fully customize their ride, the third section of the tutorial digs deep into the scripts that power the car prefab. Here you will find an in-depth assessment of most of the major functions and a walk-through of the actual code that drives the car.

As a bonus, thanks to Unity physics guru and car aficionado, Jonas Echterhoff, we have provided an alternate high-end physically accurate and realistic car model. The simulation does not make use of Unity’s wheel colliders, but instead implements its own wheel collider in script based on Physics.Raycast. The model then uses a Pacejka “Magic Formula”- based tire model to calculate wheel forces to apply to the car, which gives more accurate results.


Download the tutorial and take it for a spin. See you on the open road.


24 replies on “Car Tutorial”

What is the meaning of this code…which is in car.js?
var turnRadius : float = 3.0 / Mathf.Sin((90 – (steer * 30)) * Mathf.Deg2Rad);

I think you are all lucky to be able to check the tutorial.
cause when I open the scenes Both complete and the track I get nothing in the viewport. it’s not about how to open and run the unity files cause I have the 3rd person tutorial and the island demo running well Also my own created simple projects.
SO any help? I’ve spent the whole day trying to get around it. I even downloaded the new Non Free Unity 3. It’s showing the objects in the hierarchy window but no mesh in the viewport just Axis and the camera icon too. which did not happen in Unity 2 on both Win Vista and XP.
Thanks in advance.

Hi,This is really super tutorial. But I have exactly the same problem, although my car is moving but does not rotate the tires. Where am I doing wrong?

This is Great Tutorial . But When i use this car script on my 3d model The Wheel are not Rolling at place what should i do

I’ve fixed it, I accidentally destroyed the hierarchy between Car and Body. I think I set the layer of Body to Car, when I should have set the layer of Car to Car, as before I didnt get the message about affecting the children. Anyhow the car moves as it should now :D

I have problems with the Body and Lower-Interior staying in place while the rest of the car is moves as it should

[…] great guys over at Unity recently posted a Car Tutorial, complete with racetrack and lots of options to tweak.  I haven’t been happy with the […]

A small update I made of the Car sample, it was frustrating playing with the
keyboard, so a digital input. Also , the alternate physic model is fine :)
Enjoy drifting with the Dogde :)

-Added cameras
-Analogic inputs (X360 Pad)
-Added some cameras: cockipt , bumper
-Disabled automatic gears & Traction control
-Rendering options (glow, SSAO, rendering quality)

it works perfectly in mac but roads & bridges are not visible in windows system.check this link

ive done the tutorial and the car drives around but the front wheels sit above the front fenders and the back wheels arnt on the car atall unless they have fallen through the ground but how can i fix this ?

@Dendrophile- Yup I’ve read those two pages over and over again since last year. Like I said, they ‘hardly’ provide resources. I did not mean they do provide any at all. Shader Lab is a language on it’s own and writing shaders is an art that takes time to perfect. I think unity (or some good samaritan like Will GoldStone) should provide some in-depth material on writing shaders. else we indie developers end up not taking full advantage of unity’s capabilities

is there a video tutorial we can follow to see how we piece this car game together because im really new at scripts and what script goes ware?

Ok, so this tutorial is really awesome (it looks like a next-gen game:)). I just think unity should work on the wheel collider a bit more so it does better for racing games. or better still make variations. I also noticed that there were a lot of custom shaders in the project. funny enough though Unity hardly provides any resources (tutorials etc.) for writing shaders in shaderlab. an area almost as grey as BOO scripting in Unity!

Hey, this is totally cool. I was just thinking about a car racing game and not quite knowing where to start with the whole cars and skidding stuff, so I am totally happy to see this thorough high-quality tutorial to work as inspiration and guide. Thanks!

traditional 2D game,
3D game,
First person shooter,
3D person Shooter,
and now a Racing Game.

The logitech is now complete.

I can now do anything pretty much any kind of Game thanks to
this Amazing tool with an Amazing community.

Thank you very much.

using your own physics is great because it’s what all racing games do. i think physx wheel colliders are just good for cars in normal games and slow cars.

Comments are closed.