From the course: AR Development Techniques 02: Lighting and Physics

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Tap on screen to place on plane: Part 3

Tap on screen to place on plane: Part 3

From the course: AR Development Techniques 02: Lighting and Physics

Start my 1-month free trial

Tap on screen to place on plane: Part 3

- [Instructor] Let's instantiate a virtual cube at the point where a raycast meets the detected plane. First, let's create a variable for the object which we want to instantiate. So I'll type in public GameObject cube. Now save the script and let's create a cube object. So right click in the hierarchy, 3D Object, Cube. Make sure the position is zero, zero and zero. Change the scale to 0.1 for all three axes. Now, we don't want this cube object to be already there in the AR scene. We want to instantiate it only when we tap on the screen. So let's create a prefab of this cube. And delete it from here. Click on the ARObjectPlacement and we have this cube variable that we created. So just drag this cube right here. Now that we have the reference to this cube, we can instantiate it when the user taps on the screen. So type in InstantiateCube. This will instantiate the cube inside the scene. Let's store the…

Contents