// Update is called once per frame void Update() { // Reset current trigger this frame currentTrigger = null; // Make sure that we want to allow raycasting if ((controller.IsGrounded == true) && (Singleton.Get <MenuManager>().PauseMenu.CurrentState == IMenu.State.Hidden)) { // Update ray-casting rayCache.origin = transform.position; rayCache.direction = transform.forward; // Ray cast if (Physics.Raycast(rayCache, out info, RaycastDistance, raycastMask) == true) { // Grab ray-casted object currentTrigger = info.collider.GetComponent <InteractionTrigger>(); // Interact with the trigger if (currentTrigger != null) { if (lastTrigger != currentTrigger) { currentTrigger.OnGazeEnter(this); } if (CrossPlatformInputManager.GetButton(GazeInteractInput) == true) { switch (currentTrigger.OnInteract(this)) { case SoundEffectType.PickUpKey: pickup.Play(); break; case SoundEffectType.DropKey: drop.Play(); break; } } } } } // Update lastTrigger if ((lastTrigger != null) && (lastTrigger != currentTrigger)) { lastTrigger.OnGazeExit(this); } lastTrigger = currentTrigger; }