Game Development Reference
In-Depth Information
Objective complete - mini debriefing
We just created a
Key
and
Door
object and placed them in our level. We also created the
function that will trigger when the character hits the
Key
and
Door
objects. For the
Door
object, we used
DoorAnimator
for
Animator Controller
. If we double-click on
DoorAn-
imator
and check the
Animator
view, we will see that there are only two animation states
and two trigger parameters to switch between the opening and closing of the door, which is
a concept similar to
PlayerAnimator
, as shown in the following screenshot:
We switched the state to
DoorOpen
when the character got the
Key
object and hit the
Door
object. Then, we waited for one second to remove our character from the scene and
switch animation back to
DoorClose
by using
Yield
and
Destroy
.
Lastly, we added the
RestartButton
prefab to the scene. This prefab is the
GUITexture
object, which we can click to reset the game after the player goes to the door.