Game Development Reference
In-Depth Information
audio.volume = 1.0f;
audio.PlayOneShot(getKeySound);
Destroy (hit.gameObject);
}
}
if (hit.tag == "Door") {
if (_hasKey) {
_gameEnd = true;
_animator.enabled = false;
audio.volume = 1.0f;
audio.PlayOneShot(doorOpenSound);
var doorAnimator : Animator =
hit.GetComponent.<Animator>();
doorAnimator.SetTrigger("DoorOpen");
yield WaitForSeconds(1);
doorAnimator.SetTrigger("DoorClose");
Destroy (gameObject);
}
}
}
}
// C# user: (Put the code inside the class)
bool _hasKey = false;
void Start () {
_hasKey = false;
}
IEnumerator OnTriggerEnter2D (Collider2D hit) {
if (!_gameEnd) {
if (hit.tag == "Key") {
if (!_hasKey) {
_hasKey = true;
audio.volume = 1.0f;
Search WWH ::




Custom Search