Lerping euler angles make entire spin

I have this script to make a lerp to the Euler Angles of a Quaternion. When the second parameter of the Lerp (to) it’s positive, works like a charm but when the second parameter it’s negative, the Transform makes an entire spin.

            if(yawNeg){
				relativeRot = -(Vector3.Lerp(
					rudders[0].localRotation.eulerAngles,//first parameter
					(maxRot * ruddersVectorRot),//second parameter
					Time.deltaTime*5));
			} else if(yawPos){
				relativeRot = Vector3.Lerp(
					rudders[0].localRotation.eulerAngles,
					maxRot * ruddersVectorRot,
					Time.deltaTime*5);
			} else {
				relativeRot = Vector3.Lerp(
					rudders[0].localRotation.eulerAngles,
					Vector3.zero,
					Time.deltaTime*5);
			}

I’ve inverted the absolute value of the Lerp so I have my desired negative value.
I know that the error resides on the yawNeg part.

What I’m doing wrong?

Here’s a screenshot, I’ve taken it with Lightshot due to Unity Answers size limitation on images.

EDIT: I’ve fotgot to say if I invert something, all messes up the rotation. Even if I invert only the second parameter or the whole Lerp. If the relativeRot Vector3 is negative, the rotation makes an entire spin.

The accepted answer here is just a workaround, and will not work in all scenarios.

The real problem here is that there is not such a thing as a negative angle, only 0 degrees through 360 degrees. So when a negative angle is set, it is converting itself to a proper angle.

Because of this, you cannot cross zero

For example, you have an Angle of 10 and you are trying to Lerp to -10.

  1. You start a lerp from 10 to -10
  2. Said lerp gets to -1
  3. Negative 1 is converted to 359 degrees
  4. Lerp now tries to Lerp from 359 to -1, causing the spin

Mathf has a LerpAngle function which will treat the value as an angle in degrees, so it will for example Lerp from 350 to 10 by increasing value instead of decreasing. Using this function you can create a AngleLerp function to replace Vector3.Lerp like so

	//Properly Lerp between two angles
	Vector3 AngleLerp(Vector3 StartAngle, Vector3 FinishAngle, float t)
	{		
		float xLerp = Mathf.LerpAngle(StartAngle.x, FinishAngle.x, t);
		float yLerp = Mathf.LerpAngle(StartAngle.y, FinishAngle.y, t);
		float zLerp = Mathf.LerpAngle(StartAngle.z, FinishAngle.z, t);
		Vector3 Lerped = new Vector3(xLerp, yLerp, zLerp);
		return Lerped;
	}

I’m not one of the experts, I’m just a hack, but I would try removing the ( - ) from
-(Vector3.Lerp…
If the rotation is relative, perhaps when the second parameter is negative the direction is already taken care of.

If I’m wrong I’d hope you don’t down vote me for trying.

Good luck.

I’ve found the answer when I was coming back to home.

I’ve rotated the Transform so the rotation is 0,180,180. That way I can substract or add the rotations without using negative degrees.

Thanks @Huacanacha and @bustedkrutch for trying to help.