// Use this for initialization void Start() { for (int i = 0; i < door.Length; i++) { doorScript = door[i].GetComponent<Door>(); doorScript.OpenSeseme(); } }
// Update is called once per frame void Update() { if (Input.GetKeyDown(KeyCode.E) && canActivate == true) { for (int i = 0; i < door.Length; i++) { doorScript = door[i].GetComponent<Door>(); doorScript.isActivated = !doorScript.isActivated; doorScript.OpenSeseme(); } } }
void OnTriggerEnter2D(Collider2D other) { if(other.gameObject.tag == "Player" && isSwitch == false || other.gameObject.tag == "Heavy Object" && isSwitch == false) { for (int i = 0; i < door.Length; i++) { doorScript = door[i].GetComponent<Door>(); doorScript.isActivated = !doorScript.isActivated; doorScript.OpenSeseme(); } } }