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
From the course: AR Development Techniques 02: Lighting and Physics
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…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
(Locked)
Plane detection overview1m
-
(Locked)
ARSession and ARSessionOrigin2m 10s
-
Point clouds and plane detection3m 40s
-
(Locked)
Deploying the app on your devices2m 50s
-
(Locked)
Tap on screen to place on plane: Part 13m 8s
-
Tap on screen to place on plane: Part 24m 28s
-
(Locked)
Tap on screen to place on plane: Part 34m
-
(Locked)
Hiding plane visualizers2m 8s
-
(Locked)
FocusSquare to place on plane13m 40s
-
(Locked)
Resetting and reloading the ARSession2m 43s
-
(Locked)
-
-
-
-
-