Unity offers many ways to navigate through and explore the 3D environments that you have created. For the first 4 versions of Unity, the First-Person and Third-Person Controllers are quite common objects to use; however, since Unity 5, we also avail of several vehicles as built-in assets that we can use to jazz-up our gameplay. In this tutorial, we will learn how to quickly and simply add, use, drive and follow (using built-in camera) the car vehicule.

Note: For this tutorial, I have initially created a terrain; however, you can, if you wish, create a box that you rescale on the x- and z-axes (and also add a texture) to simulate a ground.

[Update for 2019]

For Unity 2019, You will need to Import the Standard Assets from the Assets Store using the window initially as follows:

Open the Asset Store window: select Window | Asset Store from the top menu.

window: select from the top menu. In the search window located at the top of the window, type the words “Standard Assets”

Select (i.e., click on) the asset called “ Standard Assets (Unity Technologies) “.

“. Click on the button labeled “ Download “.

“. You may be required to login into your Unity account at this stage before you can download the assets. Once this is done, the assets will be downloaded to your computer.

At this stage, once the upload is complete, and you can click on the button called “ Import ” so that these assets can be imported into your current project.

” so that these assets can be imported into your current project. A new window will appear, that shows the content of the assets that you want to import, and you can click on the button labeled “Import” to import them all.

Once the process is complete, we can check that these have been imported properly by going to the folder Assets | Standard Assets | Vehicles, and checking that it includes both folders Aircraft and Car (we will look at the aircraft asset in the next tutorials).

Folders created for the vehicles

Go to the folder Assets | Standard Assets | Vehicles | Car | Prefabs and drag and drop the asset labeled car from its folder onto the scene view, near the First-Person Controller.

Adding the car to the environment

if you already gave a First-Person Controller in the scene, we can temporarily deactivate it so that using the arrow keys on the keyboard only moves the car, and we will also ensure that the car is now the target of (or is followed by) the main camera.

First lets include a new camera to the scene that follows the car:

Go to the folder Assets | Standard Assets | Cameras | Prefabs

Select the object FreeLookCameraRig and drag and drop it to the scene

Adding the Camera

Then set the car as the target for this camera by dragging and dropping the car object to the Target attribute of the camera.

Setting the car as a target of the camera

Then, we will deactivate the First-Person Controller since we will not be using it for navigation. To do, so, select the First-Person Controller in the scene and, using the Inspector window, deactivate this object (uncheck the box as illustrated on the next figure).

Deactivating the FPS Controller

And last, we will also deactivate the main camera, using the same technique; using the inspector deactivate this object (uncheck the box as illustrated on the next figure).

Deactivating the main camera

Once this is done, you should be able to play the scene (CTRL + P), and see the car moving as you press the arrow keys (i.e., forward and back to accelerate or stop the car).

Driving the Car

Adding vehicles to your scenes is only the beginning of your game programming journey; to be able to create your next game, you will need to use terrains, add First- or Third-Person Controllers, or even create simple indoor environments. This the reason why I have created a free course that covers all you need to know to get started with Unity in no time:

After completing In this course, you will be able to:

Create an indoor maze.

Add and use lights.

Create an island with sandy beaches, trees, water, and mountains.

Include a First-Person Controller.

Create a mini-map.

Export your scene to the web so that you can share it with friends.

This course is normally $40 but you can start for free if you enroll in the next 48hours.

Save