Unity Vive VR with Maya nCloth

curtain
smallarrows.GIF

Tutorial animated Maya Ncloth curtain imported  into Unity

In Maya:  Make a curtain
Create a snakey curve in the top view.
    
Create->Curve Tools->CV Curve Tool->
boxicon.gif   Curve degree: 3 Cubic

Select the curve.

Select Surfaces->Extrude->option.jpg
Choose Style: Distance
Input your  Extrude Length:  8
Choose Direction: Specify
Choose the Y Axis
Choose Output geometry: Polygons
     Choose Quads
     Choose Tessellation method: General
     Change U type to: Per span # of iso params
     Change V type to: Per span # of iso params
     Input Number U: 1   (If this is too jaggy, increase)
     Input Number V: 3
Click Extrude


Add nCloth dynamics
Switch to theFX Module
fx_module 

Select the curtain
Choose nCloth->Create nCloth

Constrain the curtain to an imaginary curtain rod
Select the top row of vertices
Select nConstraint->Transform Constraint

Add wind
Select the curtain
Bring up the Attribute Editor
Arrow over to the nucleus1 tab
     Under Gravity and Wind

          Change Wind Speed to 4
          Change Wind Direction to 1, 0, 1


Use the simulation to model
Make at least 3 copies from various frames of the animation:
Play the animation.
Hit the play arrow on the time slider to play and stop when you like a model. timesliderplay.jpg
Select the curtain
Choose Edit->Duplicate   Ctrl d
Choose Display->Hide Selection   Ctrl h

The copy will not have any dynamics. Do this 3 times

Delete the original nCloth and curves
Use Display->Show All to show the hidden copies
Keep the 3 duplicated curtain meshes

1 will be the base shape
Name the other 2 curtains curtain1 and curtain2


Remove invisible nCloth nodes that mess you up in Unity:
Do this before animating if you are making a blend shape for Unity.
Select File->Optimize Scene Size->option
     Select Remove: Unknown nodes

Or if that did not work:
Select one shape at a time
Select Windows->General Editors->Hypergraph: Connections
     Select the light grey node
     Hit delete
     Close the Connection window
Repeat for each shape


Blend Shape
Switch to the Modeling or the Animation Module
modeling_module  or  animation_module

Select the first curtain (base)
Choose Anim Deform->Blend Shape
(This adds blend shapes options in the channel editor)

Select curtain1 (target), use shift to select the first curtain(base) too.
(The order is important)

Choose Anim Deform-> Blend Shape->Add
Do this again for curtain2

Delete the target curtains.

Select the curtain
Open blendShape1 in the Channel Box
Animate the channel named after the second curtain between 0 and 1

The timeline should be the length of your animation.

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 separate Maya files. It will be easier to manage


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


Script to help the SteamVR simulator work
This helps throwing objects and starting animation when you do not have a headset.
Written by Alex Rickett
Download this file 
Place the file in your Assets folder
Drag and drop this script onto the Player->NoSteamVRFallbackObjects->FallbackHand in your Hierarchy


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