# Unwanted rotations with transform.RotateAround

I didn't tough i would have issues with this, but unfortunatly I did. I have a Character (which is more a pile of cube) with a body, a empty GameObject for each leg attached to the body with a join and 2 cubes for leg too. The body and the two empty gameobject are child of a Empty gamebject. The 2 cube that represent leg are both child of one of the empty gameObject. What I want to achieve is to rotate the leg around the position of its empty parent by doing this:

if(Input.GetKey("l"))
{
l_leg.transform.RotateAround(l_leg.transform.parent.transform.position, new Vector3(1,0,0), 75 * Time.deltaTime);
}


unfortunatly, I only want it to rotate on x, but all of the axis are changing, which lead to unwanted rotation. Now, I know rotations aren't independant like translations, but I don't know how to fix this. If possible, i'd prefer to rotate locked joint via script but I have now idea how, I haven't seen anything about it when I looked up]2

• Have you considered just rotating the empty parent instead, about its local x axis, no RotateAround required? – DMGregory Nov 26 '19 at 13:49
• Yes but since I want the legs to be affected by gravity, I add a rigidbody, and to connect the legs to the body, I use joints on the empties that i connect to the body object, so I can't rotate the empty. – Samuel Fyckes Nov 26 '19 at 21:57
• Sounds like you want to be rotating them with joint forces instead then. Want to add that detail to your question? – DMGregory Nov 26 '19 at 22:12
• Wait, is there anyway to lock the joint but to still rotate it on an axis with script ? – Samuel Fyckes Nov 26 '19 at 22:46