-
Notifications
You must be signed in to change notification settings - Fork 2
Tutorial ‐ Step 2
To start the creation of the Unity game, a first step consists in cloning or just downloading the Simple template Unity, branch 2024-06 and add it in the Unity Hub. You can then open it.
The first step consists in creating a new scene. In our case, we want to have a “decision maker” view from the sky. We will then create a new scene using the "Main Scene - Sky View Player" template. To create such a scene, first choose "New Scene" in the "File" Menu.
Then select the "Main Scene - Sky View Player" template.

An important point to note concerns the tags used in the model, particularly those sent with the geometries: these must have already been defined in the Unity project. To define a new tag, just inspect any game object in the scene, then in "Tag", select "Add Tag". Then click on the "+" at the end of the tag list and define the new tag.
In this tutorial, we will just add a new tag called "road" for the road agents.

In this tutorial, we'll be using the a game object to represent the player, which allows the player to move horizontally with the right joystick and vertically with the left. We will use the default value for this game object except for the movement speed. We will change the movement speed to make it faster. To do this, inspect the "XR Origin (XR Rig)" game object inside the "SkyViewPlayer" game object and set the "Move Vertical" script speed to 10 and the "Move Horizontal" script speed to 20 and the rotation speed to 10.
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: from Unity in play mode; from a VR headset. In all cases it will be necessary to launch the simulation from GAMA before, i.e. start the "vr_xp" experiment of model "traffic_model-VR.gaml".
You can now push on the "Play" button of Unity.
Inspect the "Managers/Connection Manager" from the "Main Scene" and in the "Default IP" field, set the IP of the PC running GAMA (to replace of "localhost"). Note that to work, the headset and the PC have to use the same WiFi network.
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.