Last modified 3 years ago Last modified on 2014-09-11 10:43:04

Tutorial: Complete scene with several user-controllable vehicles

1. Create a new scene and prepare the scenery

  • File > New Scene
  • GameObject > Create Other > Plane
  • GameObject > Create Other > Directional light

Alternatively you can create a terrain or import a pre-created scenery.

  • Terrain > Create Terrain
  • Play a while with the terrain tools (height, texture...)
  • Leave flat areas for the roads, or you could use the Road and Path Tool (available at the Asset Store) for creating the roads.

3. Add the control prefabs to the scene

They are located in the folder EdyVehiclePhysics/Prefabs. Add them to the root of the hierarchy:

  • Main
  • MainCamera
  • SkidMarks
  • MapCamera (optional)

Important: The position and rotation of Main and SkidMarks must be (0,0,0). Scale must be (1,1,1). Otherwise the mirrors and the skidmarks won't be displayed correctly.

Also remove the Main Camera object that was included with the empty scene.

4. Add vehicles to the scene

The cars from the Live Demo are available at the folder EdyVehiclePhysics/Prefabs/Vehicles.

You have a prefab EmptyCar as well. This car is fully functional, so you can just place the proper graphics on it.

5. Configure the scripts

  • Add each user-controlable vehicle to the list Main > CarMain script > Cars. Ensure that the Cars array contains no empty slots.
  • Main > CarMain script > MainCamera must point to the MainCamera game object.
  • MainCamera > CameraControl script > Mirror... references must point to the Mirror... game objects located as children of Main.
  • MainCamera > CameraControl script > MapCamera must point to the MapCamera gameobject (if added at step 3).

6. PLAY!

Now everything's ready and working!

7. Extras

Payload: you can reference a rigidbody at CarMain script > Payload and it will be "lifted" when pressing E. This is an element just for fun in the Live Demo, a kind of heavy box that is originally loaded at the red pickup.