VR Controls

This plugin provides VR controls, including teleportation, thumbstick motion and VR pointers to remotely grab or interact with objects. It also provides fully compatible mouse and keyboard controls.

Category:
Tags: , , , , , , , , , ,

Description

This plugin allows you to add VR controls to any existing project while maintaining the ability to use keyboard and mouse controls. On top of ensuring both VR and non-VR support to your game, this is also extremely useful to reduce development time because you don’t need to put your VR headset on and off all the time.

Demo video

Tutorial

With minimal configuration, you will be able to :

1. walk around in VR, see your motion controllers, and see a red dot where you point your right pointer and a green dot where you point your left pointer.

2. rotate your VR space with the thumbstick on your left controller, and move it with the thumbstick on your right controller. These motions are discontinuous to reduce motion sickness.

3. teleport to pointed location.

4. see your animated hands.

5. grab the object pointed by your Motion Controller, remotely.

6. grab objects with your VR hands: get close until your motion controller disappears, leaving your VR hand empty, then close your hand.

7. drop hold objects by opening your hand. This way, you can also throw objects naturally. (Some controllers have a button on the side for grabbing. In this case, release this button to drop objects).

8. interact with the object pointed by your Motion Controller. The object needs to implement “InteractableInterface” provided by this plugin for this to do anything. You can also define EnterFocus/LeaveFocus events.

9. collisions and navigation are supported. Blocking objects and volumes block movement and teleportation. You can use a NavMesh for more control over allowed areas. The screen also fades to black when your point of view goes inside a blocking object (you can customize this behavior by overriding LeaveGame/ReturnToGame functions in Blueprint).

10. use your keyboard and mouse, or other non-VR controllers, to rotate, move, interact, etc using the same functions as for the VR mode.

11. Customize every single bit as you wish. The main Blueprint is kept very simple, you can adjust the behaviour of any input mapping, use your custom meshes or materials, etc. Beside the event graph, there are a few configuration variables in the “VR space” category.

In VR, unlike with a keyboard, you don’t have access to many buttons. The unified interaction interface makes it possible to implement many different kinds of interactions and easily choose which one to use both in VR and with the keyboard and mouse. In VR, just hold the trigger and point toward the desired interaction icon before releasing the trigger. With the mouse, scroll to select the desired icon, then click.

Moreover, both types of controls use, as much as possible, the same code, minimizing the opportunities for bugs and inconsistencies.

Technical Details

Main

* A VrSpace pawn class (C++) handles the VR headset and motion controllers. It provides Move/Rotate functions that you can directly bind to input events.

* A simple InteractableInterface, that other classes can implement in Blueprint or C++, handles interaction events. These events can be triggered by the VR controls provided by this plugin, keyboard and mouse controls, or any Blueprint or C++ code that implement the InteractorInterface.

* A VrPointerComponent class (C++) keeps track of what object it is pointing to and handles grabbing, interaction with interactable objects, teleporting things to the pointed location (such as the player or other objects).

* A BP_VrSpace pawn class (Blueprint) links input events (both from motion controllers and from mouse/keyboard) to the above classes, so that all the above features are ready to use immediately.

* BP_VrPlayerController and BP_VrGameMode blueprints.

* Interaction icons assets.

* SteamVR animated hands assets.

Code Modules:

* VrControls (Runtime)

* InteractableInterface (Runtime)

Number of Blueprints: 5

Number of C++ Classes: 8

Network Replicated: Not tested

Supported Development Platforms: Windows 10 (Should also work for other platforms)

Supported Target Build Platforms: Windows 10 (Should also work for other platforms)

Tested Hardware: Valve Index, Oculus Quest 2 (Should also work for other platforms)

Documentation: See the tutorial link above.

Example Project: https://drive.google.com/file/d/1YaEjqDqDeQ0TfEuJ98Amz_zexk0Hl-2m/view?usp=sharing

Supported Engine Versions

4.26 – 4.27, 5.0 – 5.3