예제 #1
0
        /// <summary>
        /// Triggers how close the grabber is to start grabbing a nearby object, informing the snapping system.
        /// </summary>
        /// <param name="factor">Current normalised value for the grab attemp, 1 indicates a grab.</param>
        private void NearGrab(float factor)
        {
            if (factor == 0f)
            {
                OnGrabAttemp?.Invoke(null, 0f);
                return;
            }

            (Grabbable, Collider)closestGrabbable = FindClosestGrabbable();
            if (closestGrabbable.Item1 != null)
            {
                OnGrabAttemp?.Invoke(closestGrabbable.Item1.gameObject, factor);
            }
            else
            {
                OnGrabAttemp?.Invoke(null, 0f);
            }
        }
예제 #2
0
        /// <summary>
        /// Triggers how close the grabber is to start grabbing a nearby object, informing the snapping system.
        /// </summary>
        /// <param name="factor">Current normalised value for the grab attemp, 1 indicates a grab.</param>
        protected void NearGrab(float factor)
        {
            if (factor == 0f)
            {
                OnGrabAttemp?.Invoke(null, 0f);
                return;
            }

            Grabbable closestGrabbable = FindClosestGrabbable();

            if (closestGrabbable != null)
            {
                OnGrabAttemp?.Invoke(closestGrabbable.gameObject, factor);
            }
            else
            {
                OnGrabAttemp?.Invoke(null, 0f);
            }
        }