Immerseum SDK: VR Simulator (version: BETA-0.9)
      [view as: Desktop | Tablet | Mobile]
Managing Your Controllers
In This Topic

One of the great things about VR is its ability to bring your hands into an interactive, immersive, digital world. That creates lots of great, immersive new design opportunities for us. But if we don't have our position-tracked controllers with us, or if we're working somewhere we can't wildly swing our arms around, that can make developing and testing things a little difficult. And then when we realize that the SteamVR plugin doesn't render controller models if there are no controllers detected, and that Oculus Utilities for Unity plugin doesn't render controller models at all - well, all of that can be a bit of a pain.

The VRSimulator helps with that by generating visible controller models and positioning them more-or-less where you might expect a player's hands to be. You can then use these simulated controllers to emulate player movement and test your interactions. For example, do you want your controllers to knock things off of surfaces in a particular way? Well, just simulate a controller and knock it into something.

If enabled, the VRSimulator:

Be Aware Be Aware

Always remember that the VRSimulator is using your virtual reality camera rigs to display VR content on your regular (non-HMD) monitor.

By design, both the SteamVR plugin and Oculus Utilties for Unity optimize rendering for a stereoscopic display in an HMD. The compositors they use to render monoscopically in Unity Play Mode create varying degrees of visual distortion, creating a sort of fish-eye lens effect.

This will make objects in your VR scene look strange - sometimes very close, sometimes far away - when you view them on your screen. If you put your HMD on and take it off to look at your on-screen view, the distortions are pretty apparent. This is particularly apparent when you look at the simulated controllers generated by the VRSimulator.

By design, the VRSimulator does nothing to compensate for this distortion - it just uses the VR camera rigs as they are, and positions its simulated controllers in worldspace so that they would "look right" rendered in your VR HMD.

This is an intentional design choice, meant to maintain positional, rotational, and scaling consistency between your simulated VR environment and your actual VR environment. If we were to position the simulated controllers so that they seemed undistorted on a regular monitor, then they would not interact with the rest of your VR scene the way your player's actual VR controllers would.

Sorry about the distortion - but the consistency in design and positioning for your actual VR experience is really worth it.

Enabling Controller Simulation

By default, the VRSimulator does not simulate position-tracked controllers. To simulate controllers, you need to turn this feature on. You can do so by modifying the HMDSimulator's Settings in the Unity Inspector. Simply make sure that Simulate Controllers is enabled, and automatically the VRSimulator will simulate controllers whenever you enter Play Mode.

 

When Simulate Controllers is enabled, new configuration settings will appear in both the HMDSimulator and ControllerManager scripts.

Be Aware Be Aware
Testing has shown that the SteamVR plugin will only enable position-tracked controllers when an HMD is detected, so it is not currently possible to test real controllers with a simulated HMD.

Designing Your Simulated Controllers

When the VRSimulator generates your simulated controllers, it can either create them as:

This is configured in the HMDSimulator's Controller Primitive setting, where you can choose from:

 

The basic shapes are all standard Unity Primitive Types. Their default scale is (1, 1, 1), but you can scale them down to more-closely resemble actual hands or hand-sized controllers. To do that, just adjust the Controller Scaling setting. By default, this setting is set to 0.05 (thus reducing their size by 95%).

Be Aware Be Aware
If using a standard primitive, both the primitive and its scaling are applied to both controllers. If you want different simulated controllers for the player's right or left hand, then you must use a Custom Controller Primitive.

If you set the Controller Primitive to Custom, you can also specify the prefab to use for your Left Controller and Right Controller. You can use any prefab from your project's Assets folder - just drag the prefab into the Left Controller and Right Controller setting, as needed.

You will note that you cannot adjust the Controller Scaling setting for Custom Controller Primitives. That is because the simulated controllers will automatically apply whatever scaling their prefab already has configured.

Setting Your Simulated Controllers' Initial Positions

You can set your simulated controllers' initial positions in the ControllerManager's settings in the Unity Inspector. Adjust the Starting Position selector to change their initial position. Your options are:

Origin Simulates "dangling at your waist". They start at more-or-less waist height (lower if seated) and slightly forward of your player avatar's implied body. This slight forward simulation is because players rarely have controllers at rest when in a VR experience, and this lets you more accurately see where your controllers are when in simulation mode.
Origin Position

Origin Position

Forward

(default)

Simulates "resting on your desk/keyboard". They are at about torso-height and more substantially forward.
Forward Position

Forward Position

Reaching Simulates hands extended out from the shoulder.
Reaching Position

Reaching Position

Boxer Simulates a "puglist's pose" with the hands near eye-level, with one (the primary) hand higher and more forward than the secondary hand.
Boxer Position (Primary Hand: Left)

Boxer Position (Primary Hand: Left)

Prefab Uses whatever position automatically derives from the simulated controller's primitive (useful if you're using a custom prefab to simulate a controller).

You can also configure which of your two controllers should be considered the player's Primary Hand. Your options here are simply Left, Right, or Ambidextrous (for both controllers). This setting affects how your hands are positioned if selecting Boxer pose.

Best Practice Best Practice

Depending on the design of your VR experience, you may want the user's left-hand controller to do different things from the right-hand controller.

Even if you aren't using the Boxer pose, the Primary Hand setting, whose value the ControllerManager class exposes as a public property, can be useful when building and testing such differentiated controller logic.

For More Information...

By adjusting the Controller Height Adjustment you can further tweak how the controllers' are initially positioned. This is particularly useful if you are also using a Custom Height for your simulated camera.

Configuring Controller Behavior

Once your simulated controllers are created, they will follow your camera rig as it moves around. If you want them to move independently of the camera rig (for example, if you want to simulate the user actually doing something with their controllers) you can do so by calling ControllerManager.moveController method.

The speed with which the simulated controllers move is determined by the ControllerManager's Movement Speed setting.

Moving Controllers

To move your simulated controllers independently of the camera (i.e. to move a hand, but not the body) you need to programmatically call the ControllerManager.moveController method.

This does require scripting, but it is actually very simple. This method takes two forms:

// Moves the left-hand controller from wherever it is to the Forward position.
ControllerManager.moveController(0, ControllerPositions.Forward);

// Moves the right-hand controller from wherever it is to the Origin position.
ControllerManager.moveController(1, ControllerPositions.Origin);

As the example above shows, you can simply tell the ControllerManager to move the controller to one of the defined positions (which are all relative to the camera/user's avatar). However, if you want to move the controller somewhere else (anywhere else), you can also do so using Unity's standard coordinate system as in the examples below:

// Moves the left-hand controller to the position at (-3, 12, 3) (randomly chosen numbers)
// but leaves its rotation the same.
ControllerManager.moveController(0, Vector3(-3, 12, 3), HMDSimulator.leftController.rotation);

// Moves the right-hand controller to the position at (1, 1.5f, 1) with a new rotation
// from a Quaternion value named "myNewRotation".
ControllerManager.moveController(0, Vector3(1, 1.5f, 1), myNewRotation);
See Also

Reference

 

 


2016 Copyright © Immerseum Inc. All rights reserved.

Send Feedback