Exemple #1
0
        /// <summary>
        /// Handles the event for when a collision stops.
        /// </summary>
        /// <param name="collision">The collision information.</param>
        private void OnCollisionExit(Collision collision)
        {
            ControllerInteractable interactable = collision.gameObject.GetComponent <ControllerInteractable>();

            if (interactable != null)
            {
                interactable.OnHitEnded();
            }
        }
Exemple #2
0
        private void Awake()
        {
            _interactable = GetComponent <ControllerInteractable>();

            // event register
            _interactable.OnHitBegan   += HandleOnHitBegan;
            _interactable.OnHitEnded   += HandleOnHitEnded;
            _interactable.OnTouchBegan += HandleOnTouchingBegan;
            _interactable.OnTouchEnded += HandleOnTouchEnded;
            _interactable.OnPressed    += HandleOnPressed;
            _interactable.OnReleased   += HandleOnReleased;
        }
Exemple #3
0
        /// <summary>
        /// Handles the event for when the trigger enters.
        /// </summary>
        /// <param name="collider">The collider that entered the trigger.</param>
        private void OnTriggerEnter(Collider collider)
        {
            ControllerInteractable interactable = collider.GetComponent <ControllerInteractable>();

            if (interactable != null)
            {
                _hit = interactable;
                _hit.Touching(true);

                if (_lastHit != _hit)
                {
                    _lastHit = _hit;
                }
            }
        }
Exemple #4
0
        /// <summary>
        /// Handles the event for when the trigger exits.
        /// </summary>
        /// <param name="collider">The collider that exited the trigger.</param>
        private void OnTriggerExit(Collider collider)
        {
            ControllerInteractable interactable = collider.GetComponent <ControllerInteractable>();

            if (interactable != null)
            {
                _hit = interactable;
                _hit.Touching(false);

                if (_lastHit != null)
                {
                    _lastHit.Release();
                }

                if (_lastHit == _hit)
                {
                    _lastHit = null;
                }
            }
        }