Documentation

Unity Engine


User Manual

Script Reference

Unity Engine


connectedOrientation

Orientation of the joint frame relative to the connected Rigidbody.
Read time 1 minuteLast updated 3 days ago

Definition

  • Type: Property
  • Namespace: UnityEngine
  • Assembly: UnityEngine.PhysicsModule
public Quaternion connectedOrientation { get; set; }

Remarks

This is the rotational counterpart of Joint.connectedAnchor: together they define the joint frame on the connected body. The rotation is given in local coordinates of the connected body, or in world coordinates if there is no connected body.
If Joint.autoConfigureConnectedOrientation is enabled, then reading this property returns the orientation Unity computed from the relative rotation of the two bodies, and assigning to it has no effect on the simulation. Disable Joint.autoConfigureConnectedOrientation to control the orientation yourself.
Setting this property is the way to keep a joint's rest pose stable across disable/enable cycles. By default Unity recalculates the orientation every time the joint is enabled, so a joint that is re-enabled while its bodies are away from their rest pose adopts that distorted pose as its new zero, which in turn shifts its limits and drive targets. Capturing the auto-configured value once while the bodies are at rest and reassigning it on every re-enable avoids this.

Examples

using UnityEngine;public class StableJointFrame : MonoBehaviour{ [SerializeField] Quaternion m_RestOrientation; // Capture the joint's current anchor orientation at start up. void OnEnable() { var joint = GetComponent<Joint>(); //cache the rest orientation while we are still in auto configure mode m_RestOrientation = joint.connectedOrientation; joint.autoConfigureConnectedOrientation = false; //apply the cached rest orientation as we are now in manual mode joint.connectedOrientation = m_RestOrientation; }}