Constrain XZ while setting local Y-rotation free. How?

Hi there,

I have a game object that should be contraint to another game object’s rotation. But I want this game object to able to freely rotate around it’s own Y axis. (Because I want to rotate this game object via rigidbody.AddRelativeTorque later).

I tried around with transform.localEulerAngles and transform.eulerAngles e.g:

transform.localEulerAngles = new Vector3(planetaryOrientation.localEulerAngles.x, transform.localEulerAngles , planetaryOrientation.localEulerAngles.z);

But all attempts couldn’t manage to do what I need. The “free” axis is never the local Y axis of the game object, but seams to be the Y axis in world space.

Is there maybe an other way to set a special local axis free while the other axis are constrait to another game object??

Hinge Joints do exactly that