smallarrows.GIF

156 syllabus      site index      3D artists      past student work        DMA

Unity VR Open Close Animated Door, toggle animations

Scripts written for you by Alex Rickett, UCLA Game lab. These scripts will open an animated door and reverse to close, useful for many events, such as turning on lights. This works with SteamVR.

In Maya
Animate a door opening and save to your Unity Assets folder.


Download these script files: door_scripts.zip
Place them in your Assets folder


In Unity:

Import SteamVR
Type SteamVR in the search bar of the Asset Store tab.
(Uncheck Longbow and Samples)

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


Delete the Main Camera
Select the Main Camera in the Hierarchy and choose Edit->Delete
The Main Camera does not work so well with this script.


Setup the Model
Drag the animated model from your Assets to your Scene Hierarchy

Select the animated model in the Hierarchy

     Add Component->Physics->Box Collider (primitives already have colliders)
     (Any collider will work.)

Drag the two scripts onto your model
     BackAndForthAnimation.cs
     ClickEventsHelper.cs



In the Inspector add the name of the Clip to the Back And Forth Animation script
     If the clip is from Maya it might be named Take 001

In the Inspector, select the + to add an event to the Click Events Helper script
     Add the model to the options
    Change No Function to BackAndForthAnimation->ToggleOpen

unity_VR_door_script


Now run the game your door will open and close when you click on it.
This works with anything animated you want to start and stop.
You can assign other objects to toggle your animations such as a light switch and a light.

door



smallarrows.GIF