Add a car
The player will control a toy car that will drive towards the location of the reticle. A model for this car is provided in the Plane Detection Starter Package.
Define Car Behaviour
Create a
CarBehaviour
script inAssets/PlaneDetectionStarterPackage
. The script defines how a car moves in relation to the hit point (reticle).
2. Double click Car Prefab
in Assets/PlaneDetectionStarterPackage
to edit the prefab. Add the CarBehaviour
you've created as a component of this prefab.
Create CarManager
script
CarManager
scriptCreate a CarManager
in your project's scripts folder (Assets/Scripts
) as the following. The CarManager
defines when and how the car is initialized.
Add a CarManager
to your scene
CarManager
to your sceneIn the Hierarchy, create a new empty
GameObject
.Rename it to
Car Spawner
.Select the object you created. In the Hierarchy pane, click Add Component to add the
CarManager
component.Set up
CarManager
's dependencies by clicking on the chooser for each field:Car Prefab: In Assets, select Car Prefab.
Reticle: In Scene, select Reticle Prefab.
Test driving
Click File > Build to test your changes.
When you tap on a plane, you should see a small car appear at that location. This car will follow the reticle.