Unity VR Open Close Animated Door


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. 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)


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
In the Inspector tab:
     Uncheck Audio Listener
Target Display to Display 2

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

Setup the Door
Drag the door from your Assets to your Scene Hierarchy
(Note this uses the default Generic Animation Type for the Asset in the Inspector.)

Select the Door
in the Hierarchy
    Add Component->Physics->Box Collider

Drag the two scripts onto your door

In the Inspector add the name of the clip for the door animation Take 001

In the Inspector, select the + to add an event to the Click Events Helper script
     Add the door model to the options
     Change No Function to BackAndForthAnimation->ToggleOpen
If you do not see this option, run the game for a second, it will automatically generate.


Now run the game your door will open and close when you click on it.