๐ Running the Model / Game
๐ Prerequisitesโ
Before starting, ensure you have:
- A GAMA model adapted for VR.
- A Unity project with a scene containing the necessary prefabs to connect to GAMA.
[!TIP] See the Tutorial: From GAMA to Virtual Universe for details on designing the GAMA model and Unity project.
โ๏ธ Middleware Setup (Required)โ
Regardless of whether you run the game in the Editor or on a Headset, the middleware must be running before you start the Unity application.
- Download: Get the middleware here.
- Configuration Files: The SIMPLE tool generates two files when creating a VR Gaml file:
settings.json: Model execution conditions..env: Configuration for the modeler's workspace.
- Installation:
- Copy the generated
.envfile (located in your project folder) into the root folder of the middleware. - For detailed installation instructions, refer to the Middleware Wiki.
- Copy the generated
๐ฎ Option A: Running from Unity (Play Mode)โ
This method is best for development and testing.
Step 1: Start the Environmentโ
- Run GAMA.
- Run the Middleware. (See Getting Started).
- Open your browser and go to: http://localhost:8000/.
- Select the Game: Click on your project name in the web interface (e.g.,
traffic_model_VR).
[!NOTE] Ensure your
.envfile is correctly configured (either automatically via the generated file or manually using theEXTRA_LEARNING_PACKAGE_PATHvariable).
Step 2: Play in Unityโ
- Open the relevant Scene in Unity (it must contain a Connection Manager and a Game Manager).
- Example:
Scenes/Code Examples/Receive Static Data.
- Example:
- Click the โถ๏ธ Play button.
๐ ๏ธ Using the XR Device Simulatorโ
If you do not have a headset connected to the PC, you can simulate VR inputs using the keyboard and mouse.
1. Setupโ
- In the Project Explorer, search for
simulator. - Drag and drop the XR Device Simulator prefab into your hierarchy.
2. Configurationโ
To move faster in the scene, adjust the sensitivity in the Inspector:
- Look for Keyboard X / Y / Z Translate Speed.
- Set values to 20 for faster navigation.
3. Controlsโ
Once inside Play Mode, use the following controls:
| Action | Controls |
|---|---|
| Move Horizontal | W/A/S/D (or Z/Q/S/D depending on layout) |
| Move Vertical | E (Up) / Q or A (Down) |
| Look Around | Hold Right Mouse Button + Move Mouse |
| Toggle Controller | Press Y to toggle the Right Controller |
| Trigger Action | Press G (while controller is active) |
[!WARNING] Remove the Simulator before Building! The XR Device Simulator is for editor testing only. You must delete it from the scene before building the application for a real headset.
๐ฅฝ Option B: Running from a Headset (Standalone)โ
To run the simulation directly on a standalone headset (like a Meta Quest), follow these steps.
Step 1: Network Configurationโ
- Ensure your PC (running GAMA) and your Headset are connected to the same Wi-Fi network.
- In Unity, select the Manager / Connection Manager object.
- In the Inspector:
- Check Fixed Properties.
- In the Default IP field, replace
localhostwith your PC's Local IP Address (e.g.,192.168.1.x).
Step 2: Build and Exportโ
- Go to File > Build Profiles.
- Select Android and click Switch Platform (this may take a few minutes).
- Click Open Scene List and ensure your main scene is checked. If missing, open the scene and click Add Open Scenes.
Step 3: Deploy to Headsetโ
- Connect your headset to the PC via USB-C.
- Accept any USB debugging authorizations inside the headset.
- Note: Your headset must be in Developer Mode.
- In Unity, click Build and Run.
- Select a folder to save the
.apkfile.
Step 4: Launching on Headsetโ
- If the app doesn't launch automatically:
- Put on the headset.
- Go to your App Library.
- Select the filter dropdown (usually says "All").
- Select Unknown Sources.
- Click on your application name.