示例#1
0
 public void LostControlOfGrabbable(Grabbable grabbable)
 {
     if (activeGrabbable == grabbable)
     {
         activeGrabbable.GrabberLostControl();
         activeGrabbable = null;
     }
 }
示例#2
0
 private void HandleGripCanceled()
 {
     if (activeGrabbable != null)
     {
         activeGrabbable.LetGo();
         activeGrabbable = null;
     }
 }
示例#3
0
        public void PerformGrab(Grabbable grabbable)
        {
            if (activeGrabbable == grabbable)
            {
                return;
            }

            if (activeGrabbable != null)
            {
                activeGrabbable.LetGo();
            }

            activeGrabbable = grabbable;
            activeGrabbable.Grab(this);
        }
示例#4
0
        private void HandleGripTriggered()
        {
            var collisions = Physics.OverlapSphere(transform.position, grabRadius, grabLayer);

            Grabbable testedGrabbable = null;
            float     distance        = float.PositiveInfinity;

            for (var i = 0; i < collisions.Length; i++)
            {
                var testDistance = (collisions[i].transform.position - transform.position).sqrMagnitude;

                if (testDistance < distance)
                {
                    testedGrabbable = collisions[i].GetComponentInParent <Grabbable>();
                    distance        = testDistance;
                }
            }

            if (testedGrabbable != null)
            {
                PerformGrab(testedGrabbable);
            }
        }