Unity Vive VR with Maya Legacy Dynamics

smallarrows.GIF

Tutorial to create an animated bouncing ball imported  into Unity. The newer Ncloth dynamics do not port motion into Unity because the shape of the cloth changes with every frame of animation. Legacy dynamics do not change their shape so they can port into Unity.

In Maya:
Create Polygon Primitives->Soccer Ball

Move the ball above the Y axis

Add Legacy dynamics
Switch to theFX Module
fx_module 

Select the ball
Choose Fields/Solvers->Create Active Rigid Body
In the Channel Editor, input Initial Spin X 1

Add gravity
Select the ball
Choose Fields/Solvers->Gravity

Add a ground object
Create Polygon Primitives->Plane
Scale it up a bit
Select the plane
Choose Fields/Solvers->Create Passive Rigid Body


Preview the animation
Select
the front view.

Hit the play arrow on the time slider. timesliderplay.jpg

Stop the playback by clicking the mouse on the red square over the play arrow.



Bake the Simulation for Unity etc
Switch the Menu Set to Animation in the top left corner of the Maya window
animation_module

Select the ball.
Choose Key->Bake Simulation
The default settings will create keys for rotation, translation and scaling for every frame, using the time slider.
Select Edit->Delete by Type->Rigid Bodies
Select Edit->Delete by Type->Static Channels to clean up extra unused channels
Save your model, use the unity tutorial to connect the animation.
|
Delete the Plane, and the gravityField



In Unity:
Import SteamVR

Type SteamVR in the search bar
unity_VR_steam_plugin
Add the SteamVR Player Prefab to your scene

Select the SteamVR folder from the Project tab
Select the arrow, open InteractionSystem, open Core, select Prefabs
Drag the Player into the Hierarchy tab



Setup the Main Camera
Select the Main Camera from the Hierarchy tab
     Change Target Display to Display 2,
Change Target Eye to None in Inspector


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 to .3, hit Apply
VRCollisions_1


Use Legacy to pause the animation until selected.
Select your Maya Model in the Assets area
Switch to the Rig tab in the Inspector on the right.
     Change Animation Type to Legacy  (default was Generic)
     Hit Apply
Switch to the Animation tab
Rename Take 001 to a unique name

Select the
Maya Model in the Hierarchy

     Uncheck Play Automatically in the Inspector
     (This feature does not exists in the newer software, hence legacy)



Add Interaction to the Model
Select the Maya Model in the Hierarchy
    Add Component->Physics->Collider 
     Choose the closest shape.
     You may need to Edit the shape from Edit Collider in the Inspector.

Use Add Component

     Search for inter
     Select Interactable Button Events
Hit the + under On Trigger Down () in the Inspector

Drag and drop Maya Model from the Hierarchy onto None (obj) in the Inspector
Click the drop down menu reading No function
and choose Animation->CrossFade
Type Take 001 (use the new unique name) in the empty box below

steam_interact_anim


You can now test your scene by selecting the Play arrow. Your animated object will start its animation when you grab it with a trigger.

unity_play_arrow