Wand interactions

When you have correctly configured your Wand in MiddleVR, you can use standard interactions like :

- Navigation: navigate the VR hierarchy in the virtual world using the Wand orientation and joystick axis,

- VR First Person Controller: Control Unity First Person Controller with Wand axis/buttons.

- Action: trigger actions when a 3D node is selected by the wand and a button is pressed,

- Grabbing: grab 3D nodes to move them in the scene.

Here's the 3D representation of the wand :

The first thing you have to do is enable the Show Wand option of the VRManager :

The wand is visible and active by default.

The VRWand node has several scripts attached to it that handle and configure those interactions :

You can safely deactivate the scripts that you don't need.

As you can see in the parameter of the script VRAttach To Node, by default the Wand is attached to the HandNode. You can change the name of the node to HeadNode for example if you wanted to navigate in the direction where you look.

Navigation

The navigation is handled by one of the Navigation Interaction scripts attached to the VRWand. The VRManager parameter "Navigation Method" allows you to choose the navigation mode for you simulation.

Some of these navigation methods have a "Fly" property to lock/unlock vertical translations. This parameter can be directly checked/unchecked on the interaction script before building, but you also can press Shift-F to toggle the fly mode when the simulation is running.

When the simulation is running, it is also possible to switch the current navigation method to another by pressing Shift-N .

Table 6.2. Standard Navigation Methods

JoystickUse the Wand's joystick to navigate in the pointed direction.
ElasticStretch a virtual elastic to the direction you want to move. The more your stretch, the faster you go.
Grab WorldGrab the air with the Wand and drag yourself to your destination.

If you want to create your own navigation, simply select "None" in Navigation Method of the VRManager.

Joystick Navigation Method

You can navigate using the axis of the Wand joystick. The navigation will move the selected node (Navigation Node) in the direction that the Reference Node is pointing.

By default, the navigation is moving the CenterNode in the direction pointed by the HandNode. It will also rotate left or right if you move the horizontal axis of theWand.

If you want to strafe, point your hand to the right or to the left and press forward.

By default you will be able to fly in the scene. If you wand to stick to the current height, uncheck the Fly option.

Table 6.3. Joystick Navigation options

Direction Reference NodeMove in the direction pointed by this node. By default it will move in the direction of "HandNode".
Navigation NodeWhich node will be moved by the script. By default it will rotate "CenterNode".
Turn Around NodeThe rotation will occur around the given node. By default it will rotate around the "HeadNode". If left empty, turns around "Navigation Node".
Translation SpeedTranslation speed, in meters per second.
Rotation SpeedRotation speed, in degrees per second.
FlyAllow a free navigation (Fly) or keep the current height (Fly disabled).

Elastic Navigation Method

You can navigate by pressing the trigger button of the Wand joystick and stretching the appearing elastic gizmo that binds the Wand to it's stretch start position. The navigation will move the selected node (Navigation Node) in the direction that the elastic gizmo is pointing.

By default, the navigation is moving the CenterNode in the direction pointed by the elastic gizmo. The more the elastic is stretched, the faster the navigation is. The same concept applies to rotation: the rotation difference between now and the moment you pressed the trigger will make the Navigation Node rotate the same way.

If you want to strafe, press the trigger button and stretch the elastic to the right or to the left.

By default you will be able to fly in the scene. If you wand to stick to the current height, uncheck the Fly option.

Table 6.4. Elastic Navigation options

Reference NodeThe node that defines the start and end positions of the elastic. By default it will use the node "HandNode".
Navigation NodeWhich node will be moved by the script. By default it will move "CenterNode".
Translation SpeedTranslation speed, in meters per second.
Rotation SpeedRotation speed, in degrees per second.
Distance ThresholdThe minimum elastic stretch distance to start moving.
Angle ThresholdThe minimum rotation angle between the start and end orientations to make a rotation movement.
Use Translation XIs translation along the X axis allowed?
Use Translation YIs translation along the Y axis allowed?
Use Translation ZIs translation along the Z axis allowed?
Use Rotation YawIs horizontal rotation allowed?
FlyAllow a free navigation (Fly) or keep the current height (Fly disabled).

Grab World Navigation Method

You can grab a position in the air and drag yourself in the virtual space. The navigation will move the selected node (Navigation Node) to make the Reference Node stay static as if your hand was grabbing a handle fixed to the world.

By default, the navigation is moving the CenterNode in reference of the grabbing HandNode. It will also rotate left or right around the Reference Node if you rotate it.

If you want to strafe, grab the world and drag yourself to the right or to the left.

Table 6.5. Grab World Navigation options

Reference NodeMove relatively to this node when grabbing. By default it will be "HandNode".
Navigation NodeWhich node will be moved by the script. By default it will move "CenterNode".

Navigation Collision

You can activate the simple VRNavigationCollision script to add collisions to the navigation interaction. This script is attached to the "Wand" node. If it is enabled, VRNavigationCollision searches for an activated navigation interaction and makes sure that the specified collision node will not penetrate the scene colliders and slide over them.

Table 6.6. VRNavigationCollision script options

Collision Node NameThe name of the 3D node that will not be allowed to penetrate scene colliders. By default we use the "HeadNode" to do the collisions.
Collision DistanceThe minimum distance allowed between the collision node position and the collider surface.

Interaction

The Wand can be used to select any 3D object in your scene. You can then notify this object that a button of the wand has been pressed. You can also grab this object to move it around in a different place.

The VRWand Interaction script handles those two interactions. It has several options :

Table 6.7. VRWand Interaction options

Ray LengthLength of the ray. Any object further than this distance will not be selected.
HighlightHighlight the wand when an object is selected ?
Highlight ColorHighlight color of the wand when an object is selected.
Grab ColorHighlight color of the wand when an object is grabbed.
Repeat ActionWhen this option is enabled, will send the VRAction message every frame. If the option is disabled, will send the VRAction message only when the button is toggled.

Action

When the object is selected, it can be notified that a button is pressed on the wand. This is useful if you want to perform an action when a particular node is selected.

If you wand a node to be able to be notified, you have to attach the VRActor scripts to it. This script will enable notifications on this object. You can find the VRActor script in the MiddleVR/Scripts/Interactions folder :

Table 6.8. VR Actor options

GrabableCan this object be grabbed ?

When the Wand intersects an object that has a VRActor attached to it, it will change its color to the highlight color defined in the VRWandInteraction script options.

When an object is selected and the main button of the Wand is pressed, the Wand will send the VRAction message to it. To react to this message, the only thing you have to do is create a method called VRAction on any script attached to the object. This method will be called every time the VRAction message is sent.

You can find such a sample script in : MiddleVR/Scripts/Samples/VRActionSample.

Grabbing

If you want an object to be grabable, simply add a VRActor script to it and enable the Grabable option. When the object is selected and the main button is pressed, the object will be grabbed by the Wand, and released when the button is released.

VR First Person Controller

Unity's First Person Controller is a handy way of having a nice navigation. You can control this First Person Controller using the Wand axis and buttons.

First you have to import the MiddleVR_FPS package. You can find it in your MiddleVR/data installation folder.

This will import a new script in your project : VRFPSInputController :

Drag this script on your First Person Controller.

You can specify which node to use for direction. By default, it's the HandNode.

Note: If you want the VR hierarchy to follow the First Person Controller, you must set the Root Node parameter of the VR Manager to a node that belongs the the First Person Controller hierarchy.

Beware: The First Person Controller object's center is not on the ground, it is located 0.5m above. This means that if you set the Root Node to the First Person Controller directly, the VR hierarchy will be 0.5m too high. One solution is to create a child node of the First Person Controller that is simply offset by -0.5 on the Y axis and set the Root Node to this offset object.

Table 6.9. VRFPSInputController options

Reference NodeNode that will be used to determine the forward direction.