Creating Spatial 3D User Interface Game Objects
Christopher Coutinho · Apress eBooks · 2022
In this chapter, we’ll learn to create User Interface game objects that accept input and communicate information. The UI is an integral part of any game. It informs players about their health and score, and helps control the game’s workflow via menus and pause screens. In a non-VR game, the UI used is a Heads-Up Display, or HUD, which is placed over the top of the main screen and displays information to the player. This type of UI is known as a nondiegetic UI, meaning it doesn’t exist in the game world. Nevertheless, it directly relates to what the player sees or interacts with inside the game. Unfortunately, this nondiegetic UI approach doesn’t work well in VR, as the player can’t focus on something so close to their eyes while trying to focus on the game. It’s very distracting and uncomfortable, as it moves with the player’s head as if it has been glued on. A better and more intuitive way to display the UI is to have it positioned in the game environment. This can be achieved by using Unity’s UI and basing it on a real UI canvas. This approach is referred to as Spatial UI. However, with version 4 of the VRTK, you can create 3D spatial UIs using spatial buttons that can be interacted with via Interactors or pointers. In this chapter, we’ll try out spatial 3D buttons, which exist as game objects in your VR world, using a spatial pointer. We’ve already encountered a straight object pointer when setting up our distance grab mechanic. We’ll start out this chapter by adding a straight spatial pointer that can interact with spatial buttons made available to you in VRTK 4.