Permalink
Cannot retrieve contributors at this time
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
18 lines (17 sloc)
806 Bytes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using UnityEngine; | |
| namespace UnityHelpers | |
| { | |
| public static class JointHelpers | |
| { | |
| /// <summary> | |
| /// Sets the target rotation of the configurable joint to be the given rotation relative to the original rotation | |
| /// </summary> | |
| /// <param name="joint">The joint whose target rotation is to be set</param> | |
| /// <param name="currentRotation">The orientation you would like the joint to be in</param> | |
| /// <param name="originalRotation">The original orientation of the joint</param> | |
| public static void SetTargetRotation(this ConfigurableJoint joint, Quaternion currentRotation, Quaternion originalRotation) | |
| { | |
| joint.targetRotation = Quaternion.identity * (originalRotation * Quaternion.Inverse(currentRotation)); | |
| } | |
| } | |
| } |