protected virtual void OnArrowNocked(HVRArrow arrow) { _previousArrowSleep = arrow.Rigidbody.sleepThreshold; arrow.transform.rotation = Quaternion.LookRotation(WorldForward, NockSocket.transform.up); arrow.transform.position = NockSocket.transform.position; var grabbable = arrow.Grabbable; grabbable.ForceRelease(); grabbable.CanBeGrabbed = false; grabbable.Rigidbody.sleepThreshold = 0f; grabbable.Grabbed.AddListener(OnNockedArrowGrabbed); UpdateBowHandCollision(BowHand, grabbable, false); NockSocket.AllowGrabbing = false; Arrow = arrow; Grabbable.IgnoreCollision(grabbable); if (NockHand) { NockHand.TryGrab(NockGrabbable, true); NockHand = null; } arrow.EnableForwardGrabbable(); }
protected override void OnArrowNocked(HVRArrow arrow) { base.OnArrowNocked(arrow); SetupNockJoint(arrow); SetupRestJoint(arrow); }
public void NockArrow(HVRArrow arrow) { if (Arrow) { return; } OnArrowNocked(arrow); }
protected virtual void OnArrowRemoved(HVRArrow arrow) { this.ExecuteAfterSeconds(() => NockSocket.AllowGrabbing = true, .25f); StartCoroutine(EnableBowHandCollisionRoutine(BowHand, arrow.Grabbable)); arrow.Grabbable.Grabbed.RemoveListener(OnNockedArrowGrabbed); arrow.DisableForwardGrabbable(); }
protected override void OnArrowRemoved(HVRArrow arrow) { base.OnArrowRemoved(arrow); if (_nockJoint) { Destroy(_nockJoint); } if (_restJoint) { Destroy(_restJoint); } }
private void SetupRestJoint(HVRArrow arrow) { _restJoint = gameObject.AddComponent <ConfigurableJoint>(); var axis = Forward; _restJoint.axis = axis; _restJoint.secondaryAxis = axis.OrthogonalVector(); _restJoint.LockYMotion(); _restJoint.LockZMotion(); _restJoint.anchor = transform.InverseTransformPoint(Rest.transform.position); _restJoint.autoConfigureConnectedAnchor = false; _restJoint.connectedBody = arrow.Rigidbody; _restJoint.connectedAnchor = arrow.transform.InverseTransformPoint(Rest.transform.position); }
private void SetupNockJoint(HVRArrow arrow) { _nockJoint = NockRigidbody.gameObject.AddComponent <ConfigurableJoint>(); var axis = Forward; _nockJoint.axis = axis; _nockJoint.secondaryAxis = axis.OrthogonalVector(); _nockJoint.LockYMotion(); _nockJoint.LockZMotion(); _nockJoint.LockLinearMotion(); _nockJoint.LockAllAngularMotion(); _nockJoint.anchor = Vector3.zero; _nockJoint.autoConfigureConnectedAnchor = false; _nockJoint.connectedBody = arrow.Rigidbody; _nockJoint.connectedAnchor = arrow.NotchPointLocal; }