diff --git a/unity/Runtime/Components/Joints/MjHingeJoint.cs b/unity/Runtime/Components/Joints/MjHingeJoint.cs index 8549c738..9a997b6c 100644 --- a/unity/Runtime/Components/Joints/MjHingeJoint.cs +++ b/unity/Runtime/Components/Joints/MjHingeJoint.cs @@ -37,7 +37,14 @@ namespace Mujoco { public MjJointSettings Settings = MjJointSettings.Default; // World space rotation axis. - public Vector3 RotationAxis => transform.rotation * Vector3.right; + public unsafe Vector3 RotationAxis { + get { + if (MjScene.InstanceExists) { + return MjEngineTool.UnityVector3(MjScene.Instance.Data->xaxis + 3 * MujocoId); + } + return transform.rotation * Vector3.right; + } + } protected override unsafe void OnBindToRuntime(MujocoLib.mjModel_* model, MujocoLib.mjData_* data) { base.OnBindToRuntime(model, data); diff --git a/unity/Runtime/Components/Joints/MjSlideJoint.cs b/unity/Runtime/Components/Joints/MjSlideJoint.cs index fa63c6b2..a32895b0 100644 --- a/unity/Runtime/Components/Joints/MjSlideJoint.cs +++ b/unity/Runtime/Components/Joints/MjSlideJoint.cs @@ -35,7 +35,14 @@ namespace Mujoco { public MjJointSettings Settings = MjJointSettings.Default; // World space slide axis. - public Vector3 SlideAxis => transform.rotation * Vector3.right; + public unsafe Vector3 SlideAxis { + get { + if (MjScene.InstanceExists) { + return MjEngineTool.UnityVector3(MjScene.Instance.Data->xaxis + 3 * MujocoId); + } + return transform.rotation * Vector3.right; + } + } protected override unsafe void OnBindToRuntime(MujocoLib.mjModel_* model, MujocoLib.mjData_* data) { base.OnBindToRuntime(model, data);