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

Unlock the full course today

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

Tap on screen to place on plane: Part 1

Tap on screen to place on plane: Part 1

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

Start my 1-month free trial

Tap on screen to place on plane: Part 1

- [Tutor] In the previous video, we set up plane detection. In this video, we are going to write some code to anchor or place a virtual object on that detected plane surface when the user taps on the screen. First let's understand how exactly does object placement work. When the user taps on the phone screen, an invisible virtual raycast is projected from the device into the real world. The point where the raycast and the detected plane meets is where the virtual object gets placed or instantiated. Let me show you an example. So when the user taps on the screen, an invisible raycast is projected from the screen into the real world. The point where that raycast meets the detected plane is where this virtual cube will be instantiated. So inside the code, we have to do three things. First, detect the user touch, that is, when the user taps on the screen. Second, project a raycast. And third, instantiate a virtual cube at the…

Contents