Game Development Reference
In-Depth Information
audio.PlayOneShot(getKeySound);
Destroy (hit.gameObject);
}
}
if (hit.tag == "Door") {
if (_hasKey) {
_gameEnd = true;
_animator.enabled = false;
audio.volume = 1.0f;
audio.PlayOneShot(doorOpenSound);
Animator doorAnimator =
hit.GetComponent<Animator>();
doorAnimator.SetTrigger("DoorOpen");
yield return new WaitForSeconds(1);
doorAnimator.SetTrigger("DoorClose");
Destroy (gameObject);
}
}
}
}
6. Next, we click on the Player game object in the Hierarchy view and drag the ob-
ject inside SimplePlatform | Resources | Prefabs in the Project view to create
the Player prefab object.
7. Inside SimplePlatform | Resources | Prefabs in the Project view, we will see the
RestartButton_C# and RestartButton_JS prefab. Now, we will create a new
RestartButton from those prefabs, drag the RestartButton_C# prefab (for C#
user), and drag the RestartButton_JS prefab (for Unity JavaScript user) to the
Hierarchy view.
Tip
From now on, we will call this prefab RestartButton instead of Re-
startButton_C# or RestartButton_JS .
8. Then, let's click on the RestartButton prefab, go to its Inspector view, and set
the values of the attributes as follows:
Tag
RestartButton
Search WWH ::




Custom Search