Scripts written for you by Alex Rickett, UCLA Game lab. These SteamVR scripts will open an animated door and reverse to close, useful for many events, such as turning on lights. This works with SteamVR.
Animate a door opening and save to your Unity Assets folder.
Download these script files: door_scripts.zip
Place them in your Assets folder
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
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 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)
Change to the Animation section of the Inspector tab
Change the Clip Name to Take 001 + something descriptive
(You may use either Legacy animation or Default Animation.)
Setup the Model
Drag the animated model from your Assets to your Scene Hierarchy
Select the model in the Hierarchy
In the Inspector uncheck Play Automatically
Select the animated model in the Hierarchy
Add Component->Physics->Box Collider
(Any collider will work.)
Drag the two scripts onto your model
In the Inspector add the name of the Clip to the Back And Forth Animation script
If the clip is from Maya you named it Take 001 + something descriptive.
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
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.