// manage if player is close enough to an terminal to offer link private void OnTriggerEnter(Collider other) { if (other.CompareTag("Terminal")) { closestTerminal = other.GetComponent <TerminalInvoker>(); } else if (other.CompareTag("Platform")) { transform.parent = other.transform; } }
private void OnTriggerExit(Collider other) { if (other.CompareTag("Terminal")) { closestTerminal = null; } else if (other.CompareTag("Platform")) { transform.parent = null; } }
void Update() { // Press E to invoke invokers command if (Input.GetKeyDown(KeyCode.E) && linkedTerminal != null) { linkedTerminal.ExecuteDoor(); linkedTerminal.ExecuteLift(); } // Press Q to invoke invokers undo if (Input.GetKeyDown(KeyCode.Q) && linkedTerminal != null) { linkedTerminal.Undo(); } // Press tab near terminal to link, allowing controls if (Input.GetKeyDown(KeyCode.Tab) && closestTerminal != null) { // Unlink old terminal if (linkedTerminal != null) { linkedTerminal.Unlink(); } // Link w. new terminal linkedTerminal = closestTerminal; linkedTerminal.Link(); } // put player back on ground if off map if (transform.position.y < -3) { transform.position = new Vector3(0, 1, 0); } // restart scene with r if (Input.GetKeyDown(KeyCode.R)) { SceneManager.LoadScene(SceneManager.GetActiveScene().name); } }