01 Running a model game - project-SIMPLE/simple.toolchain GitHub Wiki
In what follows, we assume that the user has a GAMA model adapted to VR and a Unity project with at least one scene containing the prefabs needed to connect to GAMA. See the tutorial for more information on designing this GAMA model and the Unity project.
The model can be launched in two different ways: from a headset or directly from Unity in Play mode. In the following sections, we describe both options. In all cases, the middleware connected to GAMA must be running before starting the Unity application.
The middleware can be downloaded here. All the information about the running of the middleware can be found in the middleware wiki.
Note that when the SIMPLE tool generates a VR Gaml file, it also produces two additional files: settings.json, which contains information about the model to run and its execution conditions, and a .env file, which allows the modeler’s workspace to be added to the middleware. For this second file (which is hidden in the project folder), the user must copy it into the middleware folder.
To run the model/game from Unity, follow the following steps:
-
Run GAMA
-
Run the middleware: information about installing and running the middleware can be found here
- Open the page: http://localhost:8000/
- Choose the game in the middleware interface
For example, to run the game of the tutorial (Traffic_model-VR.gaml), click on "traffic_model_VR".
5. Push on the Unity Play button
Open the Scene that you want to run (it has to contain a Connection Manager and a Game manager). For example, in linked to the model "Send Static data.gaml" we will open in the "UnityVRTemplate" the Scene "Scenes/Code Examples/Receive Static Data". Then, clicks on the Play button.

To simulate the behavior of a VR player directly in the Unity Editor when pressing Play, you can use the XR Device Simulator. This allows you to test movement and interactions without launching the game on a physical VR headset.
- In the Project Explorer, search for
simulator.
- Locate the prefab named
XR Device Simulator. - Drag and drop this prefab into your scene.
The movement speed of the virtual player can be adjusted in the XR Device Simulator inspector:
- Modify the variables
Keyboard X Translation,Keyboard Y Translation, andKeyboard Z Translation.
For example, setting these values to 20 provides faster movement.

Once the game is running in Play Mode:
-
Movement (horizontal):
-
Z/S→ forward / backward -
Q/D→ left / right
-
-
Vertical movement:
-
A/E→ down / up
-
-
Head movement:
- Use the mouse to rotate the head (look around)
-
Right controller simulation:
- Press
Yto select the right controller - Press
Gto activate the trigger
- Press
Do not keep the XR Device Simulator in the scene when building the game for a real VR headset.
The simulator is intended only for editor testing and must be removed before compiling a VR build.
Connecting a headset to GAMA is the same as running Unity with GAMA. The only difference is the need to set the correct IP and build and export the application on the headset.
Go to "Managers/Connection Manager" from the Scene and in the "Default IP" field, set the IP of the PC running GAMA (to replace "localhost"). Note that the headset and the PC must use the same WiFi network to work. Be sure as well that "Fixed Properties" is checked as it allows to use the IP defined in "Default IP".
In the File Menu, choose "Build Profiles".
In this panel, select "Android" then click on "Switch platform".
Click on "Open Scene List" to select the scenes that you want to export on the headset. For example, the scene "Scene/MainScene-tuto". If the Scene is not available, open the scene in Unity, then click on "Add Open Scenes".
Then click on "Build and Run". You will need to select a file for the application. If your headset is not connected, a pop-up will appear. You will need to connect your headset and click on "Retry". To connect the headset, simply plug your headset to the computer using a USB-C cable and accept any authorization that appears. Note that the headset must be in "Developer Mode" to export the application to it.
Once the application is exported, it should start right on the headset if you have already set up a boundary. If you don't see the application running, just click on the "Meta" button on the right controller, quit the application, and run it again. To run the application, in the application panel of the headset, select applications from "Unknown source" and you should be able to find your application.