-
Notifications
You must be signed in to change notification settings - Fork 2
Tutorial ‐ Step 2
- Create a new project using the VR model
- Install the GAMA_UNITY_VR package: download the file here, Menu "Assets" -> "Import Package" -> "Custom Package...", then select the file and import all elements from it. The package includes 3 important scenes (Assets/Scenes folder): The "Start Up" menu, which is the scene launched at the start of the game; the "IP Menu", which lets you configure the IP of the computer running GAMA or the middleware; and the "Main Scene" in the Demo folder. In this tutorial, we will only modify the latter scene.
By default, the “Main Scene” includes an FPS player. This type of player is subject to gravity and moves at ground level, considering geometries with a collider as obstacles. In our case, we prefer to have a “decision maker” view from the sky. We will remove the FPS player (right-click it and then delete). In Prefabs, GAMA Link, Player, drag and drop the "GodViewPlayer" into the scene.
In the main scene, inspect the “Game Manager” in “Managers”. In the Simulation Manager, drag and drop the GodViewPlayer game object from the Main Scene to "Player". Then, as we only have one type of agent that we send to Unity ("people" agents), we will only keep one element in the "Agents", "Rotations", "Rotations coefficient", "Y Values" and "Size Factor" lists. These lists respectively represent the prefab used to represent the agents to send (in our case, the "people" agents), the rotation to apply to this prefab (according to the Y axis), the rotation coefficient to apply to it (according to the Y axis), the offset to apply along the Y axis and the size scale of the prefab. In this tutorial, we will define them respectively as for the list of agents, the "CAR" prefab (found in Assets/Prefabs/Visual Prefabs/City/Vehicles/), for Rotations, 90, for the Rotation Coefficient, - 1, for the Y value, 0.5, and 0.4, for the size factor.
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 manage multiple connections and in particular multi-player game. However, its use requires launching third-party software (middleware). As the objective of this tutorial is to launch a game with a single player, we will just use the direct connection to GAMA.
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".
Open the script file WebSocketConnector in Assets/Scripts/Gama Provider/Connection. Set DesktopMode to true, and UseMiddleWare to false.
protected bool DesktopMode = true;
protected bool UseMiddlewareDM = false; //only for Desktop mode
You can now push on the "Play" button of Unity.