Creating an Application Using the Template
Getting Started#
UNIGINE has a ready-to-use configurable C++ VR template containing a sandbox-style scene with a set of interactive objects and components that can be manipulated using VR controllers. The template provides reusable core VR interaction components, input support for VR controllers, and default scene content for interaction and testing purposes.
The world has its settings optimized for best performance in VR.
The template is created using the Component System - components attached to objects determine their functionality.
You can extend an object's functionality simply by assigning it more components. For example, the laser pointer object in the template has the following components attached:
- ObjMovable - enables grabbing and throwing an object
- ObjLaserPointer - enables casting a ray of light by the object
You can also implement custom components to extend functionality.
Key features:
|
Interactive objects:
|
Player systems:
|
Let's create a project based on the C++ VR Template.
-
Open SDK Browser and go to the Templates tab. Find the VR C++ template and click Create Project.

-
Choose a name for your project (e.g. MyVRProject), its location, the SDK version, and precision. Then click Create New Project.

-
Once the project is created, it will appear on the My Projects tab. Open it in UnigineEditor to explore the scene.

-
To open the project in an IDE, select it on the My Projects tab and click Open Code IDE.

Structure Overview#
Now, let's learn a bit more about the template structure. All components that implement the basic VR functionality are assigned to the corresponding nodes organized in the hierarchy with the vr_layer root node (see the picture below):
The project contains a number of classes implementing the VR functionality. Here is a brief overview.
VRInteractable#
This is a base class (interface) for all objects that you can interact with. It defines a basic set of interactions: grabIt, holdIt, useIt, throwIt. You can add your own type of interaction here.
The following component classes implement VRInteractable:
| # ObjMovable | Grabbing, holding and throwing objects (a ball, a pistol, whatever you can take, carry and drop). |
|---|---|
| # ObjHandle | Objects that can be turned or moved while being held (various handles, levers, valves, etc.). |
| # ObjSwitch | Objects that can be switched by grabbing (all sorts of buttons and on-off switches, including rotary ones). |
| # ObjLaserPointer | Casting a laser ray by the object. The laser pointer node has both ObjMovable and ObjLaserPointer components attached. |
VRPlayer and VRPlayerSpawner#
VRPlayer is a base class for all players. It contains declaration of baseline controls, common basic player operations, and event management.
VRPlayerSpawner detects whether a VR headset is connected at startup. If yes, it spawns the VRPlayerVR (the VR player with HMD and controller tracking). Otherwise, it spawns the VRPlayerPC (a desktop player with keyboard + mouse control for VR emulation).
The VR player uses the VRPlayerMotor for physical movement (collisions, slopes, stepping on stairs). Input is handled by VRController and its subclasses:
- VRHandController - maps physical controller buttons to abstract actions (GRAB, USE, TELEPORT, MENU, INVENTORY). This is where button remapping is done.
- VRHandTracking - maps hand gestures to the same actions (requires OpenXR or Varjo + Ultraleap).
MenuBaseUI#
This is a base class for all graphic user interfaces (GUI).
The following component classes are inherited from MenuBaseUI:
| # HandMenuSampleGui | This component implements initialization of widgets for the menu that is attached to a controller. |
|---|---|
| # MixedRealityMenuGui | This component implements initialization of widgets for the menu that is attached to the HMD. |
The template includes many more components than covered here. For a complete reference, see the VR Template Classes and Components article.
To quickly find which nodes use a specific component, right-click it in the Properties window and select Show World Nodes Using This One.
Setting Up a Device and Running#
Make sure you have installed your VR headset according to its manufacturer's instructions and that the VR runtime (SteamVR, Oculus, or the headset's native runtime) is running.
The VR Template supports any VR device that exposes input and tracking through a supported runtime backend (OpenXR, OpenVR, or Varjo). By default, VR is not initialized. To enable it, set the Stereo 3D option to the value that corresponds to your HMD (OpenXR, OpenVR, or Varjo) in the Global Options tab of the SDK Browser and click Apply.

So, we're ready to see the template in action, let's build our application for the first time.
Don't forget to set the appropriate platform and configuration settings for the project before compiling your code in Visual Studio.
Build your application in Visual Studio (Build -> Build Solution) and launch it by selecting the project on the My Projects tab of the UNIGINE SDK Browser and clicking Run.
Before running your application via the UNIGINE SDK Browser make sure that appropriate Customize Run Options (Debug version in our case) are selected, by clicking an ellipsis under the Run button.
As the application starts, learn about basic mechanics, grab and throw objects, try to teleport and interact with objects in the scene.
The information on this page is valid for UNIGINE 2.22 SDK.