private void OnTriggerStay2D(Collider2D other) { if (other.gameObject.tag == "Computer_Trigger") { myInteractionText.SetInteractionText("Press E to access your computer."); canSwitch = true; } }
private void CheckInteractions() { Ray cameraRay = mainCamera.ViewportPointToRay(Vector3.one / 2f); RaycastHit hit; IActionableObject objectHit; // We are looking towards an interactive object an in range if (Physics.Raycast(cameraRay, out hit, 1.5f, interactionMask, QueryTriggerInteraction.Collide) && hit.transform.TryGetComponent <IActionableObject>(out objectHit) && objectHit.IsInteracterActive() ) { interactText.SetInteractionText(objectHit.GetInteractionText()); currInteractiveObject = objectHit; interactText.Enable(); } else if (interactText.enabled) { interactText.Disable(); currInteractiveObject = null; } }