Unity with Vive VR with Maya Meshes

smallarrows.GIF

VR with Unity, Maya Meshes and HTC Vive

In Unity:

Start Unity (You may need to set up an account)
Select NEW

Give your project a name such as Maya_Tutorial. This will create a folder with folders inside.
Save to the Desktop.
Select 3D.
Select Create Project.

(Close the Services tab, right mouse over the tab, select Close Tab if Services is there.)


Import a VR Camera and Sensors for Vive
     Choose Window->Asset Store

     Type Steam VR Plugin in the search bar, also select FREE ONLY button
unity_VR_steam_plugin
Select the
Steam VR Plugin (the free one by Valve Corporation) and Download

Choose Import
Choose Accept All and OK a few times

Put the main view window back to Scene instead of Asset Store

     Click the Scene tab on the left

Open the arrow on the SteamVR folder from the Project tab
Select Prefabs
Drag the CameraRig into the Hierarchy tab
In the Inspector tab under Steam VR_Play Area
change Size to Calibrated, this uses the calibrated area from the headset


Add RigidBodies and colliders to Vive hand held controllers
Open the arrow for CameraRig
in the Hierarchy tab choose both of the Controllers

In the Inspector tab
: select Add Component -> Physics->RigidBody
     Turn off  Use Gravity

In the Inspector tab: select Add Component -> Physics-> Box Collider
     Input Center:    X: 0   Y: -0.04   Z: .02
     Input Size:        X: 0.14   Y: 0.07   Z: 0.05



Main Camera Settings
Select the Main Camera from the Hierarchy tab
In the Inspector tab
     Change
Target Display to Display 2.

     Change the Target Eye to None



In Maya:
Create poly models for items that do not move in your VR environment. (NURBs do not work)

Scale:
Make your active area fit within a 15 x 10 x 11.25 xyz unit area centered. (This size could vary based on the calibration of your Vive.)

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

You may need to bake or convert to blend shape certain animations that don't translate, such as some deformers, etc.     IK rigging and blend shapes should translate


Choose File->Save As select  Desktop->
Maya_Tutorial->Assets
(Or the name of your Unity Project folder.)  Maya scene files will transfer straight into your Unity file.


Any animated items should be in separate Maya files. It will be easier to manage


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



In Unity:
Select the Assets folder in the Project tab
Select each Maya file, select the Model section, change the Scale Factor in the Inspector tab to .3.
Drag each Maya file from the Assets list in the Projects tab into the Hierarchy tab.


Collisions
Add collisions to objects, floor or walls.

Select an object.
Select Component->Physics->  Capsule, Sphere or Box Collider depending on the shape of the object.

Edit the collider shape in the Inspector, choose the Edit Collider button, move the green outlines of the collider shape. (You may need to select the object from the top of its hierarchy.)

If your shape is complex you can add multiple collider shapes to one object.
Make sure Edit Collider mode is off. Select the collider in the inspector, right mouse key Copy Component and Paste Componet as New

(If you like make a prefab. Once you set up a shape with all its colliders, you can drag it from the hierarchy into the Prefabs. This will keep the collisions, it will be available to add to the scene as a copy with collisions already set up.)


Physics
Add a rigidbody to your models to make them move with gravity or collisions.

Select your object in the hierarchy, choose Component->Physics->RigidBody

Try experimenting with the settings of the rigid body on your object, especially gravity, drag, and constraints in the inspector.


Start the Steam program from Desktop:
Select the VR button

In Unity: 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 everything is connected
Make sure the hand held controllers have charged batteries
Use the Steam VR utility to recalibrate the size of the active area if necessary   
     In the small SteamVR beta window, under the down arrow, select Run Room Set-Up
    
Click on Room-Scale
Make sure the scale of your model is a similar size to the active area in the SteamVR plugin.


Play a Maya animation in Unity

From the top menu, select Assets->Create->Animation Controller, name it

Select Assets in the Project tab

Click the small arrow unity_asset_arrow  to reveal the contents of your animated object

Double click the New Animation Controller you just made.
unity_animation_controller

Drag the Take 001 icon into the Animation Controller window. (It is located under the small arrow you opened in the Assets tab.)
unity_take001

Select the object that has the animation from the Hierarchy window

In the Inspector, Animator should be checked

Click the small round circle to the right of Controller, select the controller you just added.
unity_link_anim_controller



Loop
If you would like to loop your animation:
Select the object that has the animation from the Assets window
Change to the Animations section of the Inspector
Check Loop Time
Hit Apply



Add a different environment
Select the Camera (eye) from the Hierarchy.
Open the arrow and select Camera (eye) from under the CameraRig->Camera (head).
Under Camera in the Inspector, choose Clear Flags Solid Color.
Select a new background color.

or

Select Window->Asset Store.
Filters
FREE ONLY
Type in Skybox in the ubiquitous search at the top
Hit the Magnifying glass icon.

Select the file you prefer

Select the Download button
Select Import
You can turn off everything except the Skyboxes if you prefer
Click the Import button
Open Window->Lighting
Click the small dot next to Skybox  unity_dot
Select your skybox



Testing without the Vive
Hit the Play button   unity_play_arrow
Change to Display 2 in the Game window.

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



Screen Capture Your Project Windows 10, Game Bar, Xbox App
Windows 10, Win Key + G to open, WIN Key + Alt to record


Screen Capture Your Project with OBS Studio
http://obsproject.com