PlayMode testing a door animation
Having learned the basics of PlayMode testing in the previous recipe, let’s test something non-trivial that we might find in a game. In this recipe, we’ll create a PlayMode test to ensure that a door opening animation plays when the player’s sphere object enters a collider.
A scene has been provided with the player’s sphere initialized to roll toward a red door. When the sphere hits the collider (the OnTriggerEnter
event), some code sets the door’s Animator Controller Opening variable to true
, which transitions the door from its closed state to its open state, as shown in the following screenshot:
Figure 19.18: The door will open (upward) when hit by the sphere
Thanks to the creator of the ground texture; it was designed by Starline and published at freepik.com.
Getting ready
For this recipe, a Unity package has been provided (doorScene.unitypackage
) in the 19_07
folder.