In the previous step, you programmed an application that can detect planes. These planes are reflected in your game's scene. Now, you'll add interactivity with these planes by creating an aiming reticle and a car that will drive on the detected plane's surface.
The control scheme for this app involves the player pointing their phone at a surface. In order to give clear visual feedback for the designated location, you'll use an aiming reticle.
In order to "stick" this reticle to an AR plane, use a hit test. A hit test is a technique that calculates intersections when casting a ray in a given direction. You will use a hit test to detect an intersection in the direction of your controller.
ReticleBehaviour
script1.In Assets/Script
folder, right click -> Create -> C# Script, name the C# script ReticleBehaviour
Edit ReticleBehaviour
as following:
The ReticleBehavior
script will position the reticle on the plane that hits against the controller raycast.
In the Project pane near the bottom of the screen, navigate to Assets > PlaneDetectionStarterPackage.
Place the Reticle Prefab into the scene by dragging it into the project's Hierarchy pane.
Select the reticle in the hierarchy.
In the inspector, click Add Component. Add the ReticleBehaviour
script you've created.
Click File > Build to build and test your changes asyou did before.
You should see the reticle follow your controller's raycast movements.