Setup a Vehicle from Scratch

1. Scene Setup

  1. Create a new scene and open it

  2. Create a new 3D Object -> Plane and set the following values

If no Ground Layer exists in your project, create it

2. Vehicle Setup

Create a new Game Object and add a Vehicle component. Set the Ground Layers to "Ground"

4. Drag and drop the car model from Assets/Ilumisoft/Arcade Racing Kit/Example/Models/Kenney Racing Kit/Racing Car onto the vehicle

5. Select the four wheels, add a sphere collider to them and set the Physics Material to Wheels

Setting the Wheels physics material is very important, otherwise the vehicle will not be able to move

3. Camera Setup

  1. Create a new Game Object, name it Vehicle Camera and attach it to the vehicle

  2. Add a Vehicle Camera component to the Game Object

  3. Select Cinemachine->Create Virtual Camera and attach it to the Vehicle Camera Game Object

  4. In the Vehicle Camera component, set the VmCam field to the created virtual camera

  5. Set the virtual camera inspector fields to the values in image 3.5

If the Virtual Camera is not positioned behind the vehicle after setting up the values, disable the game object, reset the transform, and then reenable the game object

Congratulations! You have created a basic vehicle from scratch. When entering playmode, the vehicle should be able to drive properly and the camera should be following up.

4. Extend the Vehicle

We created all vehicle scripts to work in a very modular way. With the basic setup, you can extend the vehicle further by adding a custom center of mass, effects, audio and UI. To see a complete example, take a look at the example scene.

Last updated