Version: Unity 7.0 Alpha (7000.0)
LanguageEnglish
  • C#

Joint.connectedOrientation

Suggest a change

Success!

Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.

Close

Submission failed

For some reason your suggested change could not be submitted. Please <a>try again</a> in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

Close

Cancel

public Quaternion connectedOrientation;

Description

Orientation of the joint frame relative to the connected Rigidbody.

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.

Additional resources: Joint.autoConfigureConnectedOrientation, Joint.connectedAnchor

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; } }