Making the story interactive
So far, we used the Timeline to drive our entire VR story experience from start to finish. But in fact, Timelines are a playable asset like others in Unity. For example, if you select the BlackbirdDirector object and look in Inspector at its Playable Director, you'll see it has a Play On Awake checkbox, and it's presently checked. What we're going to do now is not play on awake, but rather start playing on a user event, namely looking directly at the small tree for a few seconds. And when the story ends, it resets itself.
Look to play
First, we'll add a LookAtTarget encasing the small tree and then use that to trigger playing the timeline:
- Select the
BlackbirdDirector
and uncheck thePlay On Awake
checkbox - For reference, set the Tree game object Scale to its starting keyframe Scale (
0.1, 0.1, 0.1
) - In
Hierarchy
, create a cube (Create | 3D Object | Cube
) and name itLookAtTarget
- Scale and place it to encase the small tree,
Scale
(0.4, 0.5, 0.4
),Position
(0, 0.3, 0
...