Created
June 5, 2024 13:57
-
-
Save hariedo/5af83cc898c3edc6e33f314cc447c8aa to your computer and use it in GitHub Desktop.
This file contains hidden or 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
// Unity C# extension methods to the Transform class. | |
// Transform already has TransformPosition/InverseTransformPosition. | |
// Add the correct Quaternion terms to apply or find a relative rotation. | |
public static Quaternion TransformRotation(this Transform transform, | |
Quaternion localRotation) | |
{ | |
return transform.rotation * localRotation; | |
} | |
public static Quaternion InverseTransformRotation(this Transform transform, | |
Quaternion rotation) | |
{ | |
return Quaternion.Inverse(transform.rotation) * rotation; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment