0c Unity, VRTK, Maya & Vive

smallarrows.GIF

Written by Jesse Fleming, Alex Rickett, Jennifer Steinkamp

In Unity:

Start Unity

Select NEW
Give your project a name such as Maya_VRTK_Tutorial.
Select 3D.



Import SDK Assets

Choose Window->Asset Store

Type VRTK in the search bar

VRTK_1

Select the VRTK Virtual Reality Tool Kit and
Download

Choose Import  (Ignore errors, select I made a backup go ahead)



Choose
Window->Asset Store

Type SteamVR in the search bar
unity_VR_steam_plugin
Select the
SteamVR Plugin by Valve  (It is free)
Choose Import twice (Ignore errors, select I made a backup go ahead)

Select the SteamVR folder from the Project tab, Select the arrow, select Prefabs
Select the CameraRig
In the Inspector tab
change Size to Calibrated, this uses the calibrated area from the headset

:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
Setup the Main Camera to be out of the way or used later
Select the Main Camera from the Hierarchy tab
     Change Target Display to Display 2

     Change Target Eye to None in the Inspector tab
(The main camera interferes with the Vive camera if you do not do this.)


:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
In Maya: Model a room with some objects
Create poly models for items in your VR environment. (NURBs do not work)
(NOTE) In Unity, use GameObject->3D Object->Cube for your floor, this will make things easier. The floor should be at 0 in the Y axis. Avoid planes for floors, collisions will not work with planes, you need a volume.

If you have any texture maps place them in your Unity project-> Assets folder
Assign any textures from inside Maya, using the images inside your Unity project Assets folder.

Save the Maya scene file into your Unity project-> Assets
You will see your models and textures appear automatically in Unity.

Any animated items you intend to interact with should be separate Maya files. It will be easier to manage.
You may need to bake certain animations that do not transfer into Unity, such as most deformers and Ncloth, etc.
Basic IK rigging and blend shapes will transfer.

(Maya does have a utility to send files straight to a Unity project, it saves as an FBX, the scale is completely wrong. Don't use.)


:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
In Unity: Add your Maya File to your scene
Select Assets in the Project tab
Drag your Maya file from the Assets list over to the Hierarchy tab.

If your object is the wrong scale do this:
Select the Maya file in the Assets list, select the Model section in the Inspector tab, change the Scale Factor, try .3, hit Apply


:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
VRTK_1aSDK manager for VRTK, set up the CameraRig

Right mouse select Create Empty in the Hierarchy tab
     Rename Game Object to VRTK_SDKmanager in the Inspector tab
     Select VRTK_SDKmanager choose Add Component in the Inspector tab
          Search for VRTK_SDK Manager and select that



SteamVR
     Select VRTK_SDKmanager, use the right mouse in the Hierarchy tab, select Create Empty
          Rename Game Object to SteamVR
               Select
SteamVR choose Add Component in the Inspector tab
               Search for VRTK_SDK Setup and select that


In the Project tab open the Assets folder
Select the Steam VR folder
select Prefabs


Drag SteamVR and then CameraRig prefab onto SteamVR in the Hierarchy tab
VRTK_0


Select the parent SteamVR folder in the Hierarchy tab, navigate to the Inspector tab
     Select the drop down menu under VRTK_SDK Setup -> Quick Select

          Choose Steam VR  (If it does not select make sure SteamVR is running and the headset is active.)
VRTK3


Select VRTK_SDKmanager In the Hierarchy tab
In the Inspector tab click the Auto Populate button

VRTK_auto_populate


You can now test your scene by selecting the Play arrow.
   unity_play_arrow
You should be able to view your scene with the HTC Vive



:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
VRTK_1aVRTK Hand Held Controllers
Use the right mouse in the Hierarchy tab
, select Create Empty, name this VRTK_scripts

Select VRTK_scripts
and add two Create Empty, titling them LeftController and RightController





Select VRTK_SDKManager in the Inspector tab
     Drag the Left and RightController from the Hierarchy to the Inspector tab, one at a time, to the Script Aliases section

VRTK9


Attach VRTK scripts to the controllers:
Select both controllers in the Hierarchy tab, then in the Inspector tab select Add Component, search for VRTK Pointer, select that


Render the pointer beam:
Select both of the controllers in the Hierarchy tab, then in the Inspector tab select Add Component, search for VRTK_Straight Pointer Renderer, select that.


Attach the Renderer to your pointer:
First select the Left Controller in the Hierarchy tab and drag to the Pointer Renderer under VRTK_Pointer in the Inspector tab, now do the same for the RightController
VRTK11


Create controller events to activate the pointers:
Select both controllers in the Hierarchy, then in the Inspector tab select Add Component, search for VRTK Controller_Events
, select that.


You can now test your scene by selecting the Play arrow. You should be able to see a red beam from each of the controllers when touching the touch pads.
unity_play_arrow



:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
VRTK_1aTeleporter

Select VRTKScripts in the Inspector tab
     Right mouse select Create Empty from the Hierarchy tab
     Rename Game Object to PlayAreaScripts in the Inspector tab
     Select PlayAreaScripts choose Add Component in the Inspector tab
          Search for VRTK_BasicTeleport and select that


Try it, select the Play arrow, use a Controller to ground level teleport to areas of your model, click the track pad, point at a location, release, and you are there.
unity_play_arrow



:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
VRTK_1aGrab and Throw Objects

Set up collisions on your floor:
It is easier to use a Primitive cube for a floor because it already has colliders.
Use a GameObject->3D Object->Cube
    Select Add Component
in the Inspector tab


If your floor is a Maya Mesh:
     Select the floor from your Maya model in the Hierarchy tab. Expand the Hierarchy list. Select the pCube used for your floor.
     Select Add Component in the Inspector tab     (remove any words typed in the search)
          Choose Physics->Box Collider



Controllers
Make the Controllers interactive:
Select both of the controllers in the Hierarchy tab, then in the Inspector tab select Add Component, search for VRTK_Interact Touch (Script), select that.


Add grabbing to the Controllers:
Select both of the controllers in the Hierarchy tab, then in the Inspector tab select Add Component, search for VRTK_Interact Grab (Script), select that.
     Change Grab Button to Trigger Press



Grabbable Objects
Add a primitive Sphere above the floor in your scene:  GameObject->3D Object->Sphere
    
Select the Sphere
     Select Window->VRTK->Setup Interactable Object 
          Select Hold Button to Grab   (This drops the object when you release the trigger.)
          Hit Setup selected object(s) button,  close the window
Select the Sphere in the Hierarchy tab

     Select Precision Grab
in the Inspector tab (under VRTK_Child of Controller)
     (This lets you grab from the edge rather than the center.)



Grabbable Maya Objects
If you use this process to make your Maya objects grabbable, you will also need to select Add Component->Physics->Collider
If your object is complex you can add more than 1 collider.


Play your scene, grab and throw the sphere
unity_play_arrow


:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
Watch the VRTK video that explains setting up your Rig, Teleporting and Grabbing:
https://www.youtube.com/watch?v=sW9lxEUXfe8 



:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
Demo
You can download a sample Maya_VRTK_tutorial.zip and scene file with everything setup here.
     Save to your downloads folder
     On a PC Right click to Extract All...
     Place the Maya_VRTK_tutorial folder on your desktop
     Open the Assets folder
     Double click tutorial.unity

plugins etc included:
     VRTK 3.2.0
     SteamVR 1.2.2
     Unity 2017.3
     Classic Skybox, not the entire set
     CollisionSound.cs by Alex Rickett
     VRScreenRecordingHelper.cs by Alex Rickett
     EasyMouseAndKeyboadVRControls.cs by Alex Rickett to add toh VRTK simulator
    


:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

Testing without the Vive
Hit the Play button   unity_play_arrow
Change to Display 2 in the Game window.  (The Vive is using Display 1)

If the camera view does not look right, Make sure Scale is 1x in the Game window.

You can position this camera using the Scene view when the Game is not running.


Try adding a simulator to test without Vive, next tutorial.

:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
Try your Project with Vive
Start the Steam program from Desktop:
Select the VR button

Hit the Play button   unity_play_arrow

Answer
Accept All in the Steam VR plugin
popup window

Turn on the hand held controllers, put on the headset



:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
If the Vive VR is not working:
Make sure the headset and controllers are connected
Try wiggling the Headset and pressing the buttons on the controllers
Make sure the hand held controllers have charged batteries
Make sure SteamVR status utility is running
     Start Steam  unity_steam_logo
     Login
     Hit this logo in the upper right of the steam window, you can close the large window  start_steam_VR
     Ignore Display and Base Station warnings, it will work.
    
unity_steam_status
Steam Status Utility will look like this if it is ready.

Reset Steam if you don't see all the icons
     Select the down arrow next to SteamVR unity_steam_arrow
     Select Devices->Reboot Vive headset
     There is also a menu to Run Room Setup, this should be done already



:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
OBS
OBS screen capture VR documentation



:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
MORE
VRTK_1aVRTK Tutorials
VRTK Simulator, set up a simulator camera to work when you don't have a VR headset
VRTK Touch animation, touch an object to start its animation.
VRTK Interactive sound



:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

**IMPORTANT Save a spare copy of your Maya scene files and Textures in another folder away from your Unity project.