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

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

            activeGrabbable = grabbable;
            activeGrabbable.Grab(this);
        }
Exemplo n.º 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);
            }
        }