For some reason Quaternion.lerp is messing with my local scale and causing the character to warp and become skewed.
as you can see the characters on the left are un-skewed and the knight on the right is stretched. The local scale is supposed to be .25 in the xyz.
The code that handles this rotation is this. Basically i wanted a simple code that rotated the enemy AI 180 degrees when the enemy was passed by the player. I added in another condition to ensure that it wouldn’t interrupt a turn. I thought that maybe that was what was originally causing it, but it didn’t seem to help. When i set transform.rotation manually it doesn’t skew the character.
if(facingForward && transform.rotation.y != 180)
{
if (turnDir == TurnDir.None || turnDir == TurnDir.TurningForward)
{
Quaternion rot = Quaternion.Lerp(transform.rotation, Quaternion.Euler(0, 180, 0), turnDamp);
transform.rotation = rot;
turnDir = TurnDir.TurningForward;
}
//transform.rotation = Quaternion.Euler(0, 180, 0);
}
else if(!facingForward && transform.rotation.y != 0)
{
if (turnDir == TurnDir.None || turnDir == TurnDir.TurningBackwards)
{
Quaternion rot = Quaternion.Lerp(transform.rotation, Quaternion.Euler(0, 0, 0), turnDamp);
transform.rotation = rot;
turnDir = TurnDir.TurningBackwards;
}
//transform.rotation = Quaternion.identity;
}
if(lastRot == transform.rotation)
{
turnDir = TurnDir.None;
}
lastRot = transform.rotation;
}
yield return null;
}