Placing an object on a plane
We will now add the ability for the user to tap on a plane and place a 3D virtual object in the scene. There are several parts to implementing this:
- Setting up a Place Object input action when the user taps the screen.
- Writing a PlaceObjectOnPlane script that responds to the input action and places an object on the plane.
- Determining which plane and where to place the object using AR Raycast Manager.
- Importing a 3D model and making it a prefab for placing in this scene.
Let's begin by creating an input action for a screen tap.
Setting up a PlaceObject input action
We are going to use the Unity Input System package for user input. If the Input System is new to you, the steps in this section may seem complicated, but only because of its great versatility.
The Input System lets you define Actions that separate the logical meaning of the input from the physical means of the input. Using named actions is more meaningful...