Categories & Tags
Archive

Car Tutorial

April 24, 2010 in Demos, Tutorials and Tips, Technology by

carbannerI’m very excited to announce that the Demo Team has recently released a car tutorial in collaboration with our friends at Unity Studios.

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.

 

 

 

skids

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.

 

inspector

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.

openroad

Share this post

Comments (24)

Comments are closed.

24 Apr 2010, 10:03 pm
24 Apr 2010, 10:07 pm

Hoooooooray!

25 Apr 2010, 8:54 am

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.

horace
25 Apr 2010, 1:35 pm

awesome! i have waited for this since months. :)

pixnlove
25 Apr 2010, 9:10 pm

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.

ImaginaryHuman
26 Apr 2010, 2:20 am

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!

27 Apr 2010, 7:39 am

You can make prety good dynamic racing game as well with physx wheel colliders.
http://pr2.racingbeast.com/hr5.html
(cameras switching 1,2,3 – wa are still workin on gfx, shaders, etc.)

baha
27 Apr 2010, 3:09 pm

can we use this tutorial assets including the environment for our own games?

27 Apr 2010, 4:29 pm

As with all tutorials we release you can use all the assets in your own Unity projects.

Koblavi
27 Apr 2010, 5:01 pm

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!

michael
28 Apr 2010, 3:15 am

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?

28 Apr 2010, 4:32 pm

There is no planned video tutorial to accompany the written one. If you are very new to Unity I suggest going through the 3rd Person Platformer tutorial to learn the basics: http://unity3d.com/support/resources/tutorials/3d-platform-game

Dendrophile
29 Apr 2010, 3:12 pm

@Koblavi – take a look at the shaderlab tutorial here: http://unity3d.com/support/documentation/Manual/ShaderTut1.html. It’s part of the product documentation. ;-)

Koblavi
1 May 2010, 3:28 pm

@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

michael
1 May 2010, 6:52 pm

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 ?

1 May 2010, 9:09 pm

@Koblavi – Check out this 2 hour video tutorial from Amir Ebrahimi on shader programming in Unity: http://download.unity3d.com/support/resources/files/Unite08_Shaders.mov

rajesh
6 May 2010, 6:38 am

it works perfectly in mac but roads & bridges are not visible in windows system.check this linkhttp://forum.unity3d.com/viewtopic.php?p=311215&highlight=#311215

24 May 2010, 6:12 pm

http://franck.gps32.com/unitycar/index.html

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)

30 Jun 2010, 2:56 pm

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

1 Jul 2010, 12:15 am

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

kapil
13 Mar 2011, 11:48 pm

Hello
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

Dany
20 Mar 2011, 2:39 am

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?

Tiby
20 May 2011, 12:43 pm

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.

18 Jul 2011, 2:30 pm

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

Leave a Reply

Comments are closed.