smallarrows.GIF

156 syllabus      site index      3D artists      past student work        DMA

B Unity Maya Import Animation, VR

In this tutorial we will create animations in Maya that run continuously in Unity.

In Unity:
Start
Unity Hub
We are using Unity version 2019.4.10f1 for this class

Select New
Give your project a name such as B_Maya_Anim1_Tutorial

Select GameObject->3D Object->Cube

Use the Cube for the floor, scale it down in the Y axis.
Look at the Inspector tab on the right
Scale should be around 15, .1, 15 x,y,z for the floor cube.
Set Position to 0, -.05, 0
Set Cast Shadows to Off for the floor in the Inspector tab.
Re-name the cube to floor in the Inspector tab.



In Maya: Model a simple room with some animated objects, no floor.
Create poly models for the items in your VR environment. (NURBS do not work)

If you have any image 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.

Use Lambert Shaders, nothing else will transfer to Unity.



Animation, rotation example

It can be cleaner to keep animations in separate scene files.

Move the timeline over to frame 1 at the bottom of the screen.
timeslider_1

Select a poly object.

Use the channel box on the right side of the screen.
If you do not see the channel box, hit the channel button upper right side of the screen.

Highlight Rotate Y in the Channel Box
Use the right mouse key to bring up mini menu, choose Key Selected.

Change the End Time of the animation to 301
timeslider_301

Move the timeline over to frame 301.

Rotate the object 360 degrees in the Y axis

Highlight Rotate Y in the Channel Box
Use the right mouse key choose Key Selected.


Use this process for any channel that can be animated.

Change the End Time of the animation to 300
The loop will perfect playing between 1 and 300.
Unity looks at the length of the animation from the time slider to determine the length.




Preview the animation
Move the timeline over to frame 1 at the bottom of the screen.

Right mouse over the timeline to bring up the mini-menu
     select Playback Speed->Real-time

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.




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

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



:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
In Unity

Import plugin
, Steam VR Camera and Controllers for VR
Choose the Asset Store tab next to the Scene window tab
If the Asset Store says you are offline, sign out and then back in to your Unity account

Type
SteamVR in the search bar
unity_VR_steam_plugin
Select the
SteamVR Plugin by Valve  (It is free)
If you have never done this select Download first, then Import

Choose
Import in the store window

The Import Unity package window will pop-up
   Scroll down to Longbow
       Uncheck Longbow
   Scroll down to Samples
       Uncheck Samples
Select Import
Choose
Accept All if there is a SteamVR error messages.

Plugins always import into the Assets folder of your project. You can always copy or delete the SteamVR folders between projects.

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

Select the
SteamVR folder from the Project tab
Select the arrowunity_down_arrow_hierarchy, open InteractionSystemunity_down_arrow_hierarchy, open Coreunity_down_arrow_hierarchy, select Prefabs
Drag the Player into the Hierarchy tab

Unity_steam_primitives1



SteamVR Camera Settings
Simulation Camera:
Open the arrow next to Player in the Hierarchy unity_down_arrow_hierarchy
     Open the arrow next to NoSteamVRFallbackObjects unity_down_arrow_hierarchy
     Select FallbackObjects
          Change Position in Y to 0
          Change Field of View to 90  (default 60)

Grab and drop the
Game tab below the Scene tab to create a split view.

Select
Player from the Hierarchy to position and rotate the SteamVR camera. You will see the result in the Game tab



Setup the Main Camera to be out of the way
Select the Main Camera from the Hierarchy tab
In the Inspector tab:
     Uncheck Audio Listener
    
Change Target Display to Display 2

     Change Target Eye to None in the Inspector tab
(The main camera interferes with SteamVR.)



Try your Project in Sim mode.
Hit the Play button   unity_play_arrow

If you are running in Sim
mode use w a s d, q r or the arrow buttons to navigate around the scene, and the right mouse to rotate the camera. Left mouse for interactions.



:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
View your Maya Animation in Unity
Select Assets in the Project tab
Drag your Maya file from the Assets list over to the Hierarchy tab.



Adjust Maya file:
Select the Maya file in the Assets list, select the Model section in the Inspector tab
    
Change the Scale Factor to .3
     Uncheck Import Cameras 
     (Very important for VR, Maya camera interferes with VR camera.)
     Hit
Apply
unity_import_scale



Switch to Legacy Animation

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




Loop
If you would like to loop your animation:
Select the object that has the animation from the Assets window
Change to the Animation section of the Inspector tab
     Change Wrap Mode to Loop  (near top)
     Change Wrap Mode located beneath Take 001 to Loop

Hit Apply

Now your animations are all set up to run continuously.



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

Try Running your Project
Always Save your scene before playing.
Hit the Play button   unity_play_arrow

If you are running in
Sim mode use wasd,qr or the arrow buttons to navigate around the scene,



:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
EXAMPLES

http://classes.dma.ucla.edu/Fall20/156-1/projects/examples/B_Maya_anim1_player
http://classes.dma.ucla.edu/Fall20/156-1/projects/examples/C_activate_animation_player
http://classes.dma.ucla.edu/Fall20/156-1/projects/examples/table_lamp_player

:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
Publish WebGL



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



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

smallarrows.GIF



NOT USED THIS QUARTER

If the Vive VR is not working with the headset
Start Steam steam_VR1 
First time use, Steam will ask you to login, you may set up an account or use the department's account: login dmaucla password UCLAdma!
This login seems to hang. It should work OK if you try restarting your Unity project. Worse case reboot the computer.

Make sure the headset and controllers are connected
Try wiggling the Headset.
Try pressing both the round buttons on the controllers together.
Make sure the hand held controllers are charged.
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


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