private void OnTriggerStay(Collider other) { if (other.gameObject.layer == 9) { if (Input.GetKey(KeyCode.Space) && other.GetComponent <Hole>().isOpen) { closingHole = true; hole.LoseHp(fixRate); } else { closingHole = false; hole.RezetHP(); } } if (other.gameObject.layer == 10) { isUnderWater = true; if (other.transform.parent.GetComponent <Water>() && other.transform.parent.GetComponent <Water>().fillAmount >= 30) { redutor = speed * .4f; transform.GetComponentInChildren <AnimController>().anims[1].gameObjects.GetComponent <AudioSource>().clip = waterStep; } else { transform.GetComponentInChildren <AnimController>().anims[1].gameObjects.GetComponent <AudioSource>().clip = step; } if (other.transform.parent.GetComponent <Water>() && other.transform.parent.GetComponent <Water>().fillAmount >= 80) { folego -= Time.deltaTime; if (folego <= 0) { taMorreno = true; StartCoroutine(GoToMenu()); } } } if (other.gameObject.layer == 11) { if (Input.GetKey(KeyCode.Space)) { flushing = true; flushCounter += Time.deltaTime; if (flushCounter >= flushTimer && other.GetComponent <Flush>()) { other.GetComponent <Flush>().FlushAct(); } } else { flushing = false; } } /* * if(other.gameObject.layer == 12) * { * if (Input.GetKeyDown(KeyCode.Space) && other.GetComponent<Door>()) * { * Door dorComp = other.GetComponent<Door>(); * if (dorComp.isOpen) * dorComp.isOpen = false; * else dorComp.isOpen = true; * dorComp.col.enabled = dorComp.isOpen; * } * } */ }