public void GrabUpdate(CustomHand hand) { if (rightHand && leftHand) { leftIsForvard = transform.InverseTransformPoint(leftMyGrabPoser.transform.position).z > transform.InverseTransformPoint(rightMyGrabPoser.transform.position).z; bool leftIsForvardTemp = leftIsForvard; if (handleObject != null && handleObject.Count == 2) { if ((leftHand.Squeeze - rightHand.Squeeze) > SqueezeCheack && rightMyGrabPoser == handleObject[1]) { handleObject[1].transform.localPosition = new Vector3(0, 0, Mathf.Clamp(transform.InverseTransformPoint(rightHand.GrabPoint()).z, clampHandlePosZ.x, clampHandlePosZ.y)); if (leftIsForvard) { leftIsForvard = !leftIsForvard; } } if ((rightHand.Squeeze - leftHand.Squeeze) > SqueezeCheack && leftMyGrabPoser == handleObject[0]) { handleObject[0].transform.localPosition = new Vector3(0, 0, Mathf.Clamp(transform.InverseTransformPoint(leftHand.GrabPoint()).z, clampHandlePosZ.x, clampHandlePosZ.y)); if (!leftIsForvard) { leftIsForvard = !leftIsForvard; } } } if (useSecondPose && ifUseSecondPose()) { if (secondPoses.Contains(leftHand.grabPoser)) { MyRigidbody.centerOfMass = transform.InverseTransformPoint(GetMyGrabPoserTransform(rightHand).position); MyRigidbody.velocity = (rightHand.PivotPoser.position - GetMyGrabPoserTransform(rightHand).position) / Time.fixedDeltaTime * hand.GetBlendPose(); MyRigidbody.angularVelocity = GetAngularVelocities(rightHand.PivotPoser.rotation, GetMyGrabPoserTransform(rightHand).rotation, hand.GetBlendPose()); } else { MyRigidbody.centerOfMass = transform.InverseTransformPoint(GetMyGrabPoserTransform(leftHand).position); MyRigidbody.velocity = (leftHand.PivotPoser.position - GetMyGrabPoserTransform(leftHand).position) / Time.fixedDeltaTime * hand.GetBlendPose(); MyRigidbody.angularVelocity = GetAngularVelocities(leftHand.PivotPoser.rotation, GetMyGrabPoserTransform(leftHand).rotation, hand.GetBlendPose()); } } else { if (!twoHandTypeOnlyBackHandRotation) { leftIsForvardTemp = leftIsForvard; } if (twoHandTypeMiddleRotation) { if (leftIsForvardTemp) { rightHand.ToolTransform.rotation = Quaternion.LookRotation(leftMyGrabPoser.transform.position - rightMyGrabPoser.transform.position, rightMyGrabPoser.transform.TransformDirection(LocalDirectionWithPivotRight) + leftMyGrabPoser.transform.TransformDirection(LocalDirectionWithPivotLeft)); leftHand.ToolTransform.rotation = Quaternion.LookRotation(leftHand.PivotPoser.transform.position - rightHand.PivotPoser.transform.position, rightHand.PivotPoser.TransformDirection(LocalDirectionWithPivotRight) + leftHand.PivotPoser.TransformDirection(LocalDirectionWithPivotLeft)); } else { rightHand.ToolTransform.rotation = Quaternion.LookRotation(rightMyGrabPoser.transform.position - leftMyGrabPoser.transform.position, leftMyGrabPoser.transform.TransformDirection(LocalDirectionWithPivotLeft) + rightMyGrabPoser.transform.TransformDirection(LocalDirectionWithPivotRight)); leftHand.ToolTransform.rotation = Quaternion.LookRotation(rightHand.PivotPoser.transform.position - leftHand.PivotPoser.transform.position, leftHand.PivotPoser.TransformDirection(LocalDirectionWithPivotLeft) + rightHand.PivotPoser.TransformDirection(LocalDirectionWithPivotRight)); } } else { if (leftIsForvardTemp) { rightHand.ToolTransform.rotation = Quaternion.LookRotation(leftMyGrabPoser.transform.position - rightMyGrabPoser.transform.position, rightMyGrabPoser.transform.TransformDirection(LocalDirectionWithPivotRight)); leftHand.ToolTransform.rotation = Quaternion.LookRotation(leftHand.PivotPoser.transform.position - rightHand.PivotPoser.transform.position, rightHand.PivotPoser.TransformDirection(LocalDirectionWithPivotRight)); } else { rightHand.ToolTransform.rotation = Quaternion.LookRotation(rightMyGrabPoser.transform.position - leftMyGrabPoser.transform.position, leftMyGrabPoser.transform.TransformDirection(LocalDirectionWithPivotLeft)); leftHand.ToolTransform.rotation = Quaternion.LookRotation(rightHand.PivotPoser.transform.position - leftHand.PivotPoser.transform.position, leftHand.PivotPoser.TransformDirection(LocalDirectionWithPivotLeft)); } } if (leftIsForvard) { MyRigidbody.centerOfMass = transform.InverseTransformPoint(rightMyGrabPoser.transform.position); MyRigidbody.velocity = (rightHand.PivotPoser.position - rightMyGrabPoser.transform.position) / Time.fixedDeltaTime * rightHand.GetBlendPose(); MyRigidbody.angularVelocity = GetAngularVelocities(leftHand.ToolTransform.rotation, rightHand.ToolTransform.rotation, rightHand.GetBlendPose()); } else { MyRigidbody.centerOfMass = transform.InverseTransformPoint(leftMyGrabPoser.transform.position); MyRigidbody.velocity = (leftHand.PivotPoser.position - leftMyGrabPoser.transform.position) / Time.fixedDeltaTime * leftHand.GetBlendPose(); MyRigidbody.angularVelocity = GetAngularVelocities(leftHand.ToolTransform.rotation, rightHand.ToolTransform.rotation, leftHand.GetBlendPose()); } } } else //one hand { MyRigidbody.centerOfMass = transform.InverseTransformPoint(GetMyGrabPoserTransform(hand).position); MyRigidbody.velocity = (hand.PivotPoser.position - GetMyGrabPoserTransform(hand).position) / Time.fixedDeltaTime * hand.GetBlendPose(); MyRigidbody.angularVelocity = GetAngularVelocities(hand.PivotPoser.rotation, GetMyGrabPoserTransform(hand).rotation, hand.GetBlendPose()); } }
new public void GrabUpdate(CustomHand hand) { GrabUpdateCustom(hand); if (trigger) { trigger.CustomUpdate(hand); } if (recoilConfig.recoil) { myRigidbody.velocity += transform.TransformDirection(recoilConfig.recoil.localPosition / Time.fixedDeltaTime); myRigidbody.angularVelocity += PhysicalObject.GetAngularVelocities(transform.rotation, recoilConfig.recoil.rotation, hand.GetBlendPose()); } RecoilReturn(); }
new public void GrabUpdate(CustomHand hand) { GrabUpdateCustom(hand); if (magRelease && GetMyGrabPoser(hand) == triggerPoser) { MagReleaseUpdate(hand); } if (holdOpenRelease) { HoldOpenReleaseUpdate(hand); } if (GetMyGrabPoser(hand) == triggerPoser) { trigger.customUpdate(hand); } if (recoil) { MyRigidbody.velocity += transform.TransformDirection(recoil.localPosition / Time.fixedDeltaTime); MyRigidbody.angularVelocity += PhysicalObject.GetAngularVelocities(transform.rotation, recoil.rotation, hand.GetBlendPose()); } RecoilReturn(); }