Skip to main content

๐Ÿš€ Running the Model / Game

๐Ÿ“‹ Prerequisitesโ€‹

Before starting, ensure you have:

  1. A GAMA model adapted for VR.
  2. 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.

  1. Download: Get the middleware here.
  2. 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.
  3. Installation:
    • Copy the generated .env file (located in your project folder) into the root folder of the middleware.
    • For detailed installation instructions, refer to the Middleware Wiki.

๐ŸŽฎ Option A: Running from Unity (Play Mode)โ€‹

This method is best for development and testing.

Step 1: Start the Environmentโ€‹

  1. Run GAMA.
  2. Run the Middleware. (See Getting Started). Middleware Terminal
  3. Open your browser and go to: http://localhost:8000/.
  4. Select the Game: Click on your project name in the web interface (e.g., traffic_model_VR).
Middleware Interface

[!NOTE] Ensure your .env file is correctly configured (either automatically via the generated file or manually using the EXTRA_LEARNING_PACKAGE_PATH variable).

Step 2: Play in Unityโ€‹

  1. Open the relevant Scene in Unity (it must contain a Connection Manager and a Game Manager).
    • Example: Scenes/Code Examples/Receive Static Data.
  2. Click the โ–ถ๏ธ Play button.

Unity 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โ€‹

  1. In the Project Explorer, search for simulator. Search Simulator
  2. Drag and drop the XR Device Simulator prefab into your hierarchy. Drag Simulator

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.
Simulator Settings

3. Controlsโ€‹

Once inside Play Mode, use the following controls:

ActionControls
Move HorizontalW/A/S/D (or Z/Q/S/D depending on layout)
Move VerticalE (Up) / Q or A (Down)
Look AroundHold Right Mouse Button + Move Mouse
Toggle ControllerPress Y to toggle the Right Controller
Trigger ActionPress 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โ€‹

  1. Ensure your PC (running GAMA) and your Headset are connected to the same Wi-Fi network.
  2. In Unity, select the Manager / Connection Manager object.
  3. In the Inspector:
    • Check Fixed Properties.
    • In the Default IP field, replace localhost with your PC's Local IP Address (e.g., 192.168.1.x).

Step 2: Build and Exportโ€‹

  1. Go to File > Build Profiles. Build Profiles
  2. Select Android and click Switch Platform (this may take a few minutes). Switch Platform
  3. Click Open Scene List and ensure your main scene is checked. If missing, open the scene and click Add Open Scenes. Scene List

Step 3: Deploy to Headsetโ€‹

  1. Connect your headset to the PC via USB-C.
  2. Accept any USB debugging authorizations inside the headset.
  3. In Unity, click Build and Run.
  4. Select a folder to save the .apk file.

Step 4: Launching on Headsetโ€‹

  • If the app doesn't launch automatically:
    1. Put on the headset.
    2. Go to your App Library.
    3. Select the filter dropdown (usually says "All").
    4. Select Unknown Sources.
    5. Click on your application name.