4. Save the script.
Note that there is no delay on the loop sound and animation. You will be adding the animation delay to the animation length to calculate when to start the loop animation (and sound), if it exists.
Processing the Pick Event
To use the objects’ metadata, you will need to process the mouseover and pick events. The current state is used with the mouseovers to show test descriptions and names, but the pick event requires a bit of processing. It will be queried for the current cursor texture. Armed with that information, it will find the picked object’s current state and then find the object’s new state. Once it knows that, it can go through the metadata and perform the various actions associated with the new state. Along the way, you will also be making decisions about how the cursor itself will behave.
As you may recall when you were experimenting with animations, you created a series of scripts. You will now start incorporating some of their features into your Interactor script, as well as a few other variables that will make your scripting more efficient and solve issues that may crop up.
Let’s start by switching your test objects over to the script you are developing for the actual game.
1. Save the current scene as Interaction in the Scenes folder.
2. Delete Bean Group and Rock Group from the Hierarchy view (Figure 9-16).