# Setting up your project

These instructions were written for **Unity version 2022.3.4f1.** They may not work for future versions.

## Create new project

In Unity Hub create a new project with the **3D (URP)** template. Give it a name and choose its locations.

<figure><img src="/files/8spJCYU5uZt7WzsLtd1u" alt=""><figcaption></figcaption></figure>

## Install packages

1. Go to the menu item **Window > Package Manager**&#x20;
2. Switch Packages from *In Project* to **Unity Registry**\
   ![](/files/XnmHrZm9ThdocXjrZ4Fl)
3. Under *Features* install:
   * **VR** (2 packages)
4. After installing you will be prompted with a warning: "Do you want to enable the backends?" Click **"Yes"**
5. Under *Packages* install:
   * **XR Interaction Toolkit**&#x20;
   * **XR Plugin Management** (This should already be installed with VR Features)
6. A second dialog titled "*XR InteractionLayerMask Update Required*" will pop up. Click **"I Made a Backup, Go Ahead!"**
7. Before closing the *Package Manager* window, go to the *XR Interaction Toolkit* package and click on the *Samples* tab. Import **Starter Assets.**

## Edit project settings

1. Go to the menu item *Edit > Project Settings*
2. Under **XR Plug-in Management,** click the *Android* tab. Check the box for **OpenXR**
3. Under **XR Plug-in Management > OpenXR**
   * Click the "+" under *Interaction Profiles* to add a new profile for your device:
     * Quest 2 > Oculus Touch Controller Profile
     * Quest Pro > Meta Quest Touch Pro Controller Profile
   * Under OpenXR Feature Groups, check the box for **Meta Quest Support**
4. Go to **Player**:. Change **Company** and **Product Name**. Avoid spaces and symbols.

## Edit build settings

These instructions are for Mac development.

1. Go to *File > Build Settings*. Under *Platform* choose **Android**.
2. Click the button **"Switch Platform"**
3. Connect your device to your computer via USB
4. Under *Run Device* click *"Refresh"* then choose your device from the List. You may need to click allow from within the device.
5. Click **Add Open Scenes** to include the SampleScene in the build.

## Setting up the scene

### Creating the XR Origin

1. Add an XR Origin by going to the Hierarchy add **XR > XR Origin**. \ <mark style="color:red;">**NOTE:**</mark> <mark style="color:red;"></mark><mark style="color:red;">Do</mark> <mark style="color:red;"></mark><mark style="color:red;">**NOT**</mark> <mark style="color:red;"></mark><mark style="color:red;">select the XR > Device-based > XR Origin</mark>\
   ![](/files/4I0rKTu0TzVK3ZFSnwNM)
2. The select the left hand controller objects inside the Camera Offset inside the XR Origin.\
   ![](/files/Mj3gE5NDowmHyuwW3BSR)
3. On the *XR Controller (Action-based)* component of the LeftHandController click the preset menu and choose: **XRI Default Left Controller**.\
   ![](/files/ERNF6T1NLZQI8WRFupU2)
4. Repeat the above for the *RightHandController* choosing the *XRI Default Right Controller* prese&#x74;*.*

### Adding controller models

You can add models for physical controller to help show where they are in space by adding a mesh object or prefab object.

Unity provides generic controller objects for the left and right hand *XR Interaction Toolkit > \[VERSION] > Starter Assets > Prefabs > XR Origin Pieces > XR Controller Left* (and Right). Meta provides [3D models](https://developer.oculus.com/downloads/package/oculus-controller-art/?locale=en_GB) of their physical controllers.

1. Add your model or prefab as a child of your *LeftHandController* object. Make sure the nested models Transform position is set to (x: 0, y: 0, z: 0). If you add the object directly from the your *Project Assets* it should be positioned correctly.
2. After nesting your model in the *LeftHandController* object, select the *LeftHandController* and in the inspector find the section labeled *Model* in the *XR Controller* component. Click and drag the controller model from the heirarchy into the drop down box labeled **Model Prefab**.<br>

   <figure><img src="/files/kkTYmI2ZT6Txfkyr5rOq" alt=""><figcaption></figcaption></figure>
3. Repeat steps for the *RightHandController*.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://gitbook.brown.edu/bai-creative-technology/guides/virtual-reality/virtual-reality-with-unity-getting-started/setting-up-your-project.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
