public void LostControlOfGrabbable(Grabbable grabbable) { if (activeGrabbable == grabbable) { activeGrabbable.GrabberLostControl(); activeGrabbable = null; } }
private void HandleGripCanceled() { if (activeGrabbable != null) { activeGrabbable.LetGo(); activeGrabbable = null; } }
public void PerformGrab(Grabbable grabbable) { if (activeGrabbable == grabbable) { return; } if (activeGrabbable != null) { activeGrabbable.LetGo(); } activeGrabbable = grabbable; activeGrabbable.Grab(this); }
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); } }