house-chimneyTutorial 1: How to create a main menu with level loader/selector?

In this section, we show you how to create a main menu with level selection.

Go to the folder Content\Level and create a new level.

Name the level and open it by double-clicking on it.

First, we will create the environment. To do this, go to the folder Content\BasicContent\DemoRoom\Blueprint and drag the blueprint named "BP_DemoRoom", which contains the required geometry, into the scene.

Now go to the Details panel and set the coordinates to 0, 0, 0.

For this demo, we set the room size to 2 and disable the light. The reason we disable the light is because the light in the blueprint is set to "Moveable", which would consume too many resources in VR.

Now drag a Point Light from the Create panel and add it to the scene.

Set the following settings for the Point Light:

Intensity: 30

Attenuation Radius: 3000

Set the mobilty of the light actor to "Static"

Make sure the light is placed in the center of the room.

Click on Build Lighting Only to calculate the lighting information for the light you just added.

The result should look as follows: In the viewport, the red error message indicating that the lighting needs to be rebuilt should have disappeared.

Now, we’ll use the Toolspawner to bring all the assets needed for the main menu into the scene.

Start the URealXR widget and switch to the Toolspawner tab.

Under the "Logic" category, you’ll find the button "Main Menu Standalone". Click on it to add it to the viewport.

Align the display on the wall as shown below.

In the next step, we’ll configure the following parameters on the display. This display will later be used for level selection in VR.

Set the resolution to 1920 x 1080 and the window with to 400

Next, hit the "Setup Widget" Button

The result should look as follows after you’ve adjusted the position of the main menu widget in the scene.

In the next step, we will bring the Player Pawn into the scene. This allows us to interact in VR.

To do this, open the Toolspawner and click on "VR Character" in the "Logic" category.

Place the Player Pawn in front of the monitor, slightly embedded into the floor.

If we now start the VR Preview, we won’t be able to move using the teleporter yet, because it requires a Nav Mesh Bounds Volume.

To add this, type "nav" into the search bar and drag the Nav Mesh Bounds Volume into the scene.

To display the Nav Mesh and its valid area in the viewport, press the "P" key.

The walkable area in VR is now displayed in green. Since the surface is still too small, scale it along the X and Y axes until it covers the entire room.

Very well done! It is now possible to teleport around the scene using the teleporter.

In the next step, we will configure the database that is connected to the monitor and enables level presentation and selection.

The database is located in the folder Content\Database.

Double-click on the database named "DT_Trainings_VR" to open it.

The database should look as follows. Delete the existing entry by clicking on the trash bin icon.

Now we’ll create a new entry in the database from scratch. To do this, click the "Add" button. This adds a new entry to the database.

Now, let’s focus on the lower section called "Row Editor". Here, we’ll enter our descriptions for the level.

Under "Title", enter the name of the main category — for example, "Pumpe". Under "Icon", you can upload a representative image. Under "Description", enter any descriptive text you like.

In the next step, we need to assign one or more levels to the main category. We do this by clicking the plus (+) icon next to Modules.

Here, you can name the level. In our case, "Disassembly Pump" would be a suitable title. Under "Icon", you can again assign an image. By clicking the plus (+) icon next to Description, you can add a text that describes the level.

Finally, the most important step: under "Level", you must enter the exact name of the level that should be loaded. To do this, go to the Level folder and copy the name of the level that you want this module to load.

Go back to the database and paste the name into the "Level" field.

Click the Save button to save the entries.

If you now start the VR experience, you should see this result.

circle-info

Every time you load a level through the main menu and then exit that level, you will automatically return to this menu —provided it has been set up accordingly in advance.

To set this up in advance, go to the folder Content\VRAssembling\Blueprint\Game and click on the blueprint BP_GameInstance_VR.

In the Details panel, under Trainings Database, you need to assign the correct database — in our case, "DT_Trainings_VR". Under Main Menu Map, you must set the main menu level we created — in our case, [MainMenu].

Finally, go to Project Settings > Maps & Modes and set your main menu as both the Editor Startup Map and the Game Default Map. This ensures that the main menu is always the first thing loaded when the game starts.

Congratulations! You’ve now built a solid foundation that allows you to load any levels you like.

Last updated