2

I have an application which will render an augmented reality scene and a portal for which you can walk into the scene. The scene is occluded from view by a plane, but if you walk through that plane, you "bust" into the virtual environment.

I'm not looking for code but rather help on how to approach this problem. I want to make it so that the only way you can enter the virtual scene is by walking through the doorway that I've created. I first thought about tracking the location of the camera and making sure that you're very close to the entrance before you cross over the threshold to enable rendering but it seems like if I do it this way the user would not be able to see through the doorway before approaching/entering the virtual scene.

Andy Jazz
  • 49,178
  • 17
  • 136
  • 220
giraffesyo
  • 4,860
  • 1
  • 29
  • 39
  • Suggestion: use a collider inside the doorway that when triggered by the user walking through does the events you want it to do (i.e. enable rendering, etc.) – slaphshot33324 Mar 18 '19 at 13:34
  • Downvoted because this doesn’t seem like a programming question. It seems more like a logic/aesthetics question. (“What’s the best thing to do to my user if they walk through an AR wall I don’t want them to go through?” – Pro Q Mar 31 '19 at 06:12

2 Answers2

1

At first, look at How to create a Portal effect in ARKit just using the SceneKit editor? Stack Overflow post how to make a portal itself.

The robust way to prevent users from passing through virtual walls is to have the same configuration of virtual walls like real walls have (where physical wall is – the virtual wall exists too).

enter image description here

Also you need object detection tools. For precise positioning of your virtual walls over real physical walls just use Core ML framework with pre-trained small-sized mlmodel along with ARKit framework's classes like ARImageTrackingConfiguration() or ARWorldTrackingConfiguration().

enter image description here

In case you have no opportunity to build the same configuration of virtual walls like real walls were built, you can make a user's iPhone vibrate when a user has collided with a virtual wall. Here's a code:

import AudioToolbox.AudioServices

AudioServicesPlaySystemSound(kSystemSoundID_Vibrate)
AudioServicesPlayAlertSound(kSystemSoundID_Vibrate)

Hope this helps.

Andy Jazz
  • 49,178
  • 17
  • 136
  • 220
1

There are a few methods I can think of off the top of my head.

  1. Make it so that when a person walks through a wall, the whole screen goes blank except for a message telling them that they need to back away out of the wall, and maybe an arrow to tell them what direction to move.

  2. Make it so that bumping into a wall shifts the entire scene.

  3. Do a combo of the two and ask them if they’d like to shift the scene when they run far into a wall.

Pro Q
  • 4,391
  • 4
  • 43
  • 92