Step 2: Creation of the Unity basic game
๐ Prerequisitesโ
Before starting this tutorial, please ensure:
- You have correctly installed Unity and the required modules: Installation Guide.
- You are familiar with the editor's layout: Unity Interface Basics.
๐ A. Project Setupโ
1. Import the Templateโ
To start the game creation process, first clone or download the Simple Unity Template.
- Unzip the archive.
- Open Unity Hub.
- Click the Add button and select the unzipped
Unity Templatefolder.
- Once imported, click on the project name in the list to launch it.
๐ฌ B. Scene Configurationโ
Once the project is open, the first step is to create a specific scene for the simulation.
1. Create the Sceneโ
We want to establish a "decision maker" view from the sky. We will use a specific template for this.
- Go to File > New Scene (or press
Ctrl+N/Cmd+N). - Select the "Main Scene - Sky View Player" template.
- Click Create.
- Save your current scene immediately (File > Save).
2. Verification: Scene Loadingโ
[!WARNING] Sometimes, Unity may not load all references correctly upon scene creation.
How to detect a loading error: You might encounter one of the two following issues immediately after creating the scene:
- Console Error: A red error appears:
NullReferenceException: Object reference not set to an instance of an object. - Missing References: If you select the Manager object in the Hierarchy, the Player and Ground fields in the Inspector show as "None" or empty.
To fix this issue:
- Go to the Console tab and click Clear.
- Open a different scene (e.g.,
Assets/Scenes/Code Examples/Limit Player Movement). - Re-open your newly created scene.
- The error should disappear, and the Manager references should now be correctly assigned.
3. Configuration: Middleware Connectionโ
Once the scene is loaded correctly, you must verify the external connection settings.
- Select the Manager object in the Hierarchy.
- Locate the Connection Manager component in the Inspector.
- Crucial: Ensure that the Fixed Properties checkbox is enabled.
[!CAUTION] If
Fixed Propertiesis not checked, the connection to the middleware will not function correctly.
4. Troubleshooting: Lighting Warningโ
You may see a yellow warning in the Console stating:
"Lighting data asset 'LightingData' is incompatible with the current Unity version..."
To fix this:
- Go to Window > Rendering > Lighting.
- In the Lighting window, click Generate Lighting.
- Wait for the process to finish, then Clear the Console.
โ๏ธ C. Gameplay Configurationโ
1. Game Manager: Tag Configurationโ
Crucial Step: Tags sent by the model must be explicitly defined in Unity to avoid synchronization issues.
To define a new tag:
- Select any Game Object.
- In the Inspector, click the Tag dropdown > Add Tag...
- Click + and type the tag name.
[!NOTE] For this tutorial, please add a new tag named "road" (case-sensitive).
2. SkyViewPlayer Configurationโ
We will use the SkyViewPlayer prefab. To improve navigation speed:
- In the Hierarchy, expand SkyViewPlayer.
- Select the child object named Locomotion.
- In the Inspector, update the script values:
- Move Vertical Speed:
20 - Move Horizontal Speed:
20 - Rotation Speed:
10
- Move Vertical Speed:
๐ฎ D. Testing the Modelโ
You can run the simulation in two ways:
- VR Headset: Build and deploy to the device.
- Unity Editor (Play Mode): Runs directly on your computer.
[!IMPORTANT] Simulator Requirement To control the player movements within the Unity Editor (Play Mode), you must use a Simulator. Note that on some platforms (like macOS), you may need to manually set it up.
๐ Please follow the instructions in the Running a Model Game guide to properly set up the simulator.
โก๏ธ Next Step: Proceed to Step 3