private void Update()
        {
            _ray = _mainCamera.ViewportPointToRay(new Vector3(0.5f, 0.5f, 0f));
            if (Physics.Raycast(_ray, out _hit, _maxRayDistance, _interactableLayer))
            {
                if (Input.GetKeyDown(KeyCode.E))
                {
                    _hit.collider.GetComponent <IInteractable>().Interact();

                    _isReadyToInteract = false;
                    OnInteractionUnavailable?.Invoke();
                }
                else if (!_isReadyToInteract)
                {
                    _isReadyToInteract = true;
                    OnInteractionAvailable?.Invoke();
                }
            }
            else
            {
                if (_isReadyToInteract)
                {
                    _isReadyToInteract = false;
                    OnInteractionUnavailable?.Invoke();
                }
            }
        }
예제 #2
0
        private void OnTriggerExit(Collider other)
        {
            playerInRange = false;


            OnInteractionUnavailable?.Invoke(interactable.interactionType);
        }
예제 #3
0
        public void TriggerInteraction()
        {
            if (!active)
            {
                Debug.LogWarning(name + ": this trigger is not active. Not Triggering interaction");
                return;
            }

            if (interactionType != InteractionTriggerTypes.OnInput)
            {
                return;
            }

            interactable.Interact();

            if (disableAfterTrigger)
            {
                active = false;
                OnInteractionUnavailable?.Invoke(interactable.interactionType);
            }
        }