private void Release() { Vibrate(0.5f, 0.08f); if (_interactible.Release()) { ShowController(); _interactible = null; } }
public void Grab(int index, bool grab) { if ((int)_index != index) { return; } _grabbing = grab; GrabFeedback(grab); if (_interactible != null) { if (!grab) { Release(); } return; } if (!grab) { DisableCollider(); return; } var hits = Physics.SphereCastAll(transform.position, GrabRange, transform.forward, GrabRange); foreach (var hit in hits) { if (hit.transform == transform) { continue; } _interactible = hit.transform.GetComponent <HandInteractible>(); if (_interactible == null) { continue; } if (FitGrabbed()) { return; } } EnableCollider(); }
private bool FitGrabbed() { Vibrate(1f, 0.12f); if (_interactible.OnGrab(transform)) { HideController(); DisableCollider(); return(true); } _interactible = null; return(false); }