If you couldn’t attend the our Presence Platform Workshop during fall semester, don’t worry! This blog will walk you through everything you need to know to get up to speed.
What can you do with the Presence Platform?
Add support for hand tracking and passthrough
Make objects grabbable
VR user interfaces
Virtual keyboard
And more!
Prerequisites:
Meta Quest Account: Ensure you have a Meta Quest account to log in.
GitHub Account: If you don’t have one yet, create a GitHub account at github.com.
Step 1: Set up Unity - VizLab
Open the ‘CAEN Software’ app from your desktop. It’s one of the icons. We can run all the software we need from here without having to download it on the Vislab computers.
Look up ‘Unity’ and launch the 2022.3.20f1 version.
Step 2: Clone the project
Go to Github and log in to your account. Then click this link navigate to ARI’s presence demo: https://github.com/Alternate-Reality-Initiative/PresenceWorkshop
Copy the project files to your computer using HTTPS cloning. Click Code then select HTTPS and copy the link.
To clone onto your Desktop, go back to your CAEN Software tab and look up ‘git’ and click on ‘Git for Windows 2.41.0.3’. This will make sure you have access to the git command line tools in your terminal. To copy the project files to an appropriate location, open File Explorer and navigate to This PC-> Windows -> Users -> <your_uniquename>. Right click. Select ‘Open in Terminal’. Type in ‘git’ and press enter. You should see a list of git commands. If you see a message saying that git is unrecognized, let us know.Then, you can type in git clone <link from github> to clone your project into your folder (no angle brackets). Let us know if you have any issues or see any errors.
Step 3: Open the Project in Unity
In Unity Hub, click the ‘Add’ button on the top right corner and navigate to the project folder, Then click ‘Open’.
Your project should now be open. To create a new scene, navigate to the ‘Scenes’ folder. There, you should see a sample scene which has the complete demo. This is the scene you will be building today! Let’s check it out. Double click the scene.
Step 3.5: Configure the headset
In your headset, go to Settings → Physical Space → Passthrough and make sure Passthrough is on. Then go to Movement Tracking→ Hand Tracking→ and turn on Hand and Body Tracking. Go into the Oculus app on the computer (log in) and go to Settings → General and toggle on the ‘Unknown Sources’ option. Also in the Oculus App go to Settings → Beta and toggle on Developer Runtime Features and Passthrough over Meta Quest Link.
If you don’t see those options, you need to make your account a Developer Account. Go to developer.oculus.com and log in. Then go to My Apps. Then Create an Organization. Give it whatever name you want. Then just follow the prompts. You don’t need to create an App. Then go back to the Oculus desktop app, log out, and log back in. Under Settings→Beta you should now see Developer Runtime Features. Enable Passthrough over Meta Quest Link.
Step 4: Try the Demo Scene in the Headset
Put on your headset and go to Settings then Quest Link. Activate Quest Link by clicking Launch. You might have to go into the Oculus App (make sure you’re logged in to your account) to link with cable. If it doesn’t work at first, try to unplug the headset and plug it in again (the plug should be on the left side of the headset).
Then, in your Unity editor, press the Play button in the middle of the top bar and put your headset on. You should see the scene. Let us know if passthrough doesn’t work (seeing the real world in the background) or if hand tracking doesn’t work (you should be able to see virtual hand models overlaid on your physical hands). Keep in mind that you need to have the controllers set flat on a surface and not moving for hand tracking to activate.
You should be able to pick up the blocks on the floor with your hands and throw them at the target. They should disappear when they hit the target.
Step 5: Let’s build it ourselves!
Right click in the Scenes folder and click Create → Scene. Name it whatever you want. Double click to enter that scene. This is the scene you will be working in. It should be empty.
Quick overview of the different panels. Your layout may be configured differently.
The Hierarchy shows a tree-like list of all the objects in your scene. The Inspector shows details about a specific object, like what components are attached to it. You can select something in the HIerarchy to see its details in the Inspector. The Project panel shows your in-project files. And the Scene view shows the actual scene.
Delete the Main Camera object by selecting it in the Hierarchy, right clicking it and choosing Delete. We will replace the generic camera with a VR-ready camera.
Step 6: Add Building Blocks
To add a building block, go to Oculus dropdown on the top of the screen and go down to Tools. Under Tools, select Building Blocks.
Oculus→Tools→Building Blocks
You can basically just drag and drop these building blocks into your scene to use them in your application! For those familiar with Unity, this is basically the same as just adding a prefab into the scene.
The first thing you need to add to your scene is the Camera Rig block. Then the Passthrough block. Now you should be able to put on the headset, press Play, and see the real world through the headset. If you can’t, let us know and we can help. Don’t forget to unpress Play again when you take the headset off. Any changes made in Play mode are temporary.
Next, add the Hand Tracking building block and the Virtual Hands block and press play. In the headset, you should be able to see your hands being tracked. Now we have all the basic VR functionality we want: Camera rig, hand tracking, and passthrough!
Step 7: Let’s build out the game logic
Add the ‘Camera Rig’ and ‘Passthrough’ building blocks to the scene. The camera rig is what makes this a VR application where you can see 3D objects in your space and the passthrough component is what makes this application an MR (mixed reality) application.
Make objects:
Drag the ‘Grab Interaction’ building block into your scene hierarchy.
Click on the new Cube object. In the inspector, scroll down to the ‘Rigidbody’ component. If ‘Is Kinematic’ Is checked, deselect it. Uncheck ‘Is Trigger’ as well.
The ‘Grab Interaction’ block has multiple dependencies (hand tracking, virtual hands). We have these components in the scene, but if we didn’t we wouldn’t have to worry about adding them in because adding this block takes care of that for us.
Create the floor
Click the add button in the top right of your Hierarchy tab and select 3D Object->Plane. Move it down in the editor so that it shows up below your cubes and scale it down by 0.2 in the object’s inspector tab (under transform->scale)
Create the target object
In the Hierarchy panel (list of objects in the current scene), select the plus button in the top left and select 3D Object –> Cylinder to create your target object.
Select your cylinder object. In the Inspector, you will see all the properties of the cylinder. Under Transform you can change the position and rotation. We want to change it so that the Y scale is 0.02 and the X rotation is 90. Once we test in VR we can adjust the orientation as needed.
Make it so we can hit the target
To make the target interactable, we need to use a Collider component. Think of this like a hitbox in the shape of the target. To see the current bounds, select your cylinder in the Hierarchy. In the Inspector, you should see a Capsule Collider component.
If you click the button to the right of “Edit Collider” you can see the bounds of the collider.
These bounds aren’t quite what we’re looking for, so we want to replace the Capsule Collider with a Box Collider. Click the three dots on the far right of the Capsule Collider and choose “Remove Component”
Then go to Add New Component (bottom option in the Inspector) and type in Box Collider then add the Box Collider component. If you click the button next to Edit Collider on this new collider, you should see that the bounds line up much better.
Select ‘Add component’ again in the inspector and search for ‘rigidbody’. Add the component and next to ‘Is Kinematic’ check the box. This will make it so that the target stays in place.
Next, click ‘Add component’ again and select ‘New Script’ in the drop down. You will be making a simple script so make blocks disappear as they hit the target. Name the script and double click to open it.
You might have to go back into your CAEN app search tab and search for Visual Studio Code and launch it to be able to edit your script. If your CAEN tab isn’t responding, close and reopen it.
Paste this function into the script:
void OnCollisionEnter(Collision c){
c.gameObject.SetActive(false);
}
This is an event based function provided to us by Unity. Upon collision, this function will be evoked. We get the reference to the game object. SetActive(false) is a function that deactivates the game object to make it look like it has disappeared.
Step 8: Test!
Put on the headset and then press Play to run your app. Everything should be working similar to the demo! Let us know if anything is not working as expected!