AniMate - Local and Global rotation

I’m using the AniMate package to create animations for my rigid bodies, but I am encountering a problem whereby all of the rotation commands are trying to move towards a global value, not a local value how I want them to.

I used the following code to create an arm that swings to the left and right with the keypresses “a” and “d” respectively:

if (Input.GetKeyDown ("a"))
Ani.Mate.To(transform, 0.5, {"rotation":
Quaternion.Euler(50,0,0), "drive": Ani.Drive.Slerp});

if (Input.GetKeyDown ("d"))
Ani.Mate.To(transform, 0.5, {"rotation":
Quaternion.Euler(-50,0,0), "drive": Ani.Drive.Slerp});

The result is not what I want however. If the basecube of the arm topples over to the side then I noticed that the movements of the arm are trying to pull it towards a global X rotation instead of relative to it’s joint to the basecube.

Is there a solution?

Quaternion.Euler(mod(basecube.rotation.eulerAngles.x+50, 360), 0,0) and
Quaternion.Euler(mod(basecube.rotation.eulerAngles.x-50, 360), 0,0) could do it (untested).

float mod(float a, float b) {
return a - b * Mathf.Floor(a / b);
}
Edit: Mod works different to what i expected

Can’t get it to work. Is there something else similar to AniMate?

Quaternion.RotateTowards maybe