Skip to content

Running a model game

ptaillandier edited this page Jul 19, 2024 · 5 revisions

Preamble

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.

General information

The model can be launched in different ways: from a headset/directly from unity in play mode - with/without middleware. The middleware makes it possible to better manage the connections between GAMA and Unity and is mandatory in the context of a multi-player game. It is thus recommended to use it.

We will see in the following two ways to launch the game with the middleware: from Unity in play mode; from a VR headset. In all cases it will be necessary to run the middleware, connect GAMA to it, and launch the simulation from GAMA before, i.e. start the Unity experiment of the GAMA model.

The middleware can be downloaded here. All the information about the running of the middleware can be found in the middleware wiki.

Running the model/game

From Unity

To run the model/game from Unity, follow the following steps:

  1. Run the middleware
  • If you're using Windows: run start.bat, located in the project root directory.
  • If you're using MacOS or Linux: run start.sh, located in the project root directory.
Terminal - running the middleware

The middleware will open a new page (http://localhost:8000) on your default web browser. if this page does not appear, just reload the page.

You should then get this page: Middleware - start

  1. Run GAMA This step can be done before step 1. In this case, the middleware is connected directly to GAMA and you can proceed to step 4.

  2. Connect GAMA to the middleware On the middleware web page, click on "Try Connection". GAMA should after be connected (appearing in green).

Middleware - GAMA connected
  1. Launch the experiment In GAMA, runs the experiment integrating the connection with Unity. As an example, we will run the experiment "vr_xp" of the model provided with GAMA's Unity plugin: "Plugin models/LinkToUnity/Models/Code Examples/Send Static data.gaml"
GAMA - run xp

On the middleware web page, you should be able to see the status of the experiment in orange ("simulation paused") Middleware - xp ok

  1. 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.
Unity - Play
  1. Add the player On the middleware web page, you should see the player trying to connect to the middleware in orange. Click the Add button to add it.
Middleware - player

The middleware should turn green and you will see the geometry sent by GAMA in Unity.

Middleware - ok Result - Unity

From a headset

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.

Open the 3 Scenes (Startup Menu, IP Menu and Main Scene) and connect the headset to the computer (and authorize the connection). In the File Menu, choose "Build Setting". In this panel, select "Android" then click on "Switch platform". In the "Scene in Build" panel, be sure to have the three Scene (first, Startup Scene, then IP Menu and at last, Main Scene). Then, click on Build and Run.

Build-setting

Clone this wiki locally