void SetTargetRotation(AnimatedPair pair) { ConfigurableJoint joint = pair.RagdollBone.Joint; if (joint.configuredInWorldSpace) { joint.SetTargetRotation(pair.currentPose.worldRotation, pair.RagdollBone.StartingJointRotation); } else { joint.SetTargetRotationLocal(pair.currentPose.localRotation, pair.RagdollBone.StartingJointRotation); } }
// Update is called once per frame void FixedUpdate() { // Update the target rotation for this gameobject // TODO: This isn't taking into account the rotation of the player RB configurableJoint.SetTargetRotation(Quaternion.Inverse(configurableJoint.connectedBody.transform.rotation) * targetTransform.rotation, startRotation); // Update the remote anchor to point to the target transform configurableJoint.connectedAnchor = Quaternion.Inverse(configurableJoint.connectedBody.transform.rotation) * (targetTransform.position - configurableJoint.connectedBody.position); if (snapDistanceEnabled) { if ((transform.position - targetTransform.position).magnitude > snapDistance) { SnapToTrueHand(); } } if (touchCount <= 0) { rb.MoveRotation(Quaternion.Lerp(transform.rotation, targetTransform.rotation, rotationLerpSpeed)); } }
private void FixedUpdate() { FollowTarget(Time.deltaTime); target.SetTargetRotation(m_ResultRotation, m_OriginalRotation); }
public static void SetTargetRotation(this ConfigurableJoint joint, Quaternion targetWorldRotation) { joint.SetTargetRotation(targetWorldRotation, joint.transform.rotation); }