Add a car
Last updated
Last updated
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.
Create a CarBehaviour
script in Assets/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.
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.
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.
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.