Welcome to The Desert
Objective: Enable Oculus pass-through feature & build a VR portal from my apartment to a virtual world & back
VR build Software: Unity 2020.3.19f1 and C# in Visual Studio
HMD: Oculus Quest 2
Date: 7-8th February 2022
Result
Notes: Could add more portals - making my apartment a hub to many different worlds. Some doors might not have a way back too.
Integrate MRTK to allow for hand interaction with GameObjects to pull portal doors open & close.
Process/Documentation Below
Features
Oculus pass-through feature
VR portal
On trigger play audio & animation
Pass-Through feature settings to enable
- Enable passthrough property & Underlay Placement
- Tracking origin type to floor level not eye
Change background type to Solid Color & Color to black
IL2CPP & ARM64 enabled in player settings
Universal Render Pipeline Forward Renderer settings - Add ‘Portal’ & ‘Inside Portal’
Rigidbody is kinematic to avoid physics interactions with other objects but allow for on trigger events.
Clipping plane near value changed to 0.05 to match with sphere collider radius (Not shown in image)
Portal Trigger Script
Notes:
- TargetTag string to assign Main Camera as collider
- doorAudioSource to assign when opening
- doorAnimator to assign to door opening animation upon player proximity to the door
- Upon trigger enter between maincamera(center eye anchor) with portal trigger box collider, play audio & fulfill ‘Opening’ parameter to initiate door opening animator
- Center eye anchor Rigidbody is kinematic to not be affected by other physical objects but register on trigger events
GIF of door opening
Door trigger box collider without mesh render. “Is Trigger” ticked
After assigning pass-through material for “insideportal” layers(layer 6), desert game objects no longer visible in editor mode.
Mask layer (Layer 7) applied to quad game object that makes up the portal ‘see-through’ window
Quad Gameobject assigned as ‘mask’ layer(Layer 7) to become portal entry window
Quad as portal from desert —> reality assigned ‘passthroughportal’ material with mixed reality ‘selective passthrough’ shader. Layer remains as default.
“Opening” parameter enabled upon collision to allow transition between Door idle to Door Opening animation state
Portal Script
Notes:
- “Target tag” string to assign to main Camera (Center eye anchor)
- Gameobject list to assign desert gameobjects to be visible only after entering portal space
- new layer integer to assign to as default layer(layer 0 in this case)
- OnTriggerEnter with main camera tag, change layer of each desert gameobject from insideportal(6) to new layer(assigned as 0 in inspector)