Skip to content

Instantly share code, notes, and snippets.

View boringuser's full-sized avatar

Eric Williams boringuser

  • Microsoft
  • Seattle, WA
View GitHub Profile
@mstevenson
mstevenson / ConfigurableJointExtensions.cs
Last active March 26, 2025 03:55
Unity extension methods for computing a ConfigurableJoint.TargetRotation value from a given local or world rotation.
using UnityEngine;
public static class ConfigurableJointExtensions {
/// <summary>
/// Sets a joint's targetRotation to match a given local rotation.
/// The joint transform's local rotation must be cached on Start and passed into this method.
/// </summary>
public static void SetTargetRotationLocal (this ConfigurableJoint joint, Quaternion targetLocalRotation, Quaternion startLocalRotation)
{
if (joint.configuredInWorldSpace) {