/// <summary> /// The StartGrab method sets up the grab attach mechanic as soon as an Interactable Object is grabbed. /// </summary> /// <param name="grabbingObject">The GameObject that is doing the grabbing.</param> /// <param name="givenGrabbedObject">The GameObject that is being grabbed.</param> /// <param name="givenControllerAttachPoint">The point on the grabbing object that the grabbed object should be attached to after grab occurs.</param> /// <returns>Returns `true` if the grab is successful, `false` if the grab is unsuccessful.</returns> public override bool StartGrab(GameObject grabbingObject, GameObject givenGrabbedObject, Rigidbody givenControllerAttachPoint) { CancelUpdateRotation(); CancelDecelerateRotation(); bool grabResult = base.StartGrab(grabbingObject, givenGrabbedObject, givenControllerAttachPoint); previousAttachPointPosition = controllerAttachPoint.transform.position; grabbedObjectBounds = VRTK_SharedMethods.GetBounds(givenGrabbedObject.transform); limitsReached = new bool[2]; CheckAngleLimits(); grabbingObjectReference = VRTK_ControllerReference.GetControllerReference(grabbingObject); return(grabResult); }
protected override void OnDrawGizmosSelected() { base.OnDrawGizmosSelected(); if (hingePoint != null) { Bounds rotatorBounds = VRTK_SharedMethods.GetBounds(transform, transform); Vector3 limits = transform.rotation * ((AxisDirection() * rotatorBounds.size[(int)operateAxis]) * 0.53f); Vector3 hingeStart = hingePoint.transform.position - limits; Vector3 hingeEnd = hingePoint.transform.position + limits; Gizmos.DrawLine(hingeStart, hingeEnd); Gizmos.DrawSphere(hingeStart, 0.01f); Gizmos.DrawSphere(hingeEnd, 0.01f); } }