Hi,
I’m using the Vector3.SignedAngle to determine the rotation direction of a steeringwheel.
All working fine until the steeringwheel crosses the 0 degrees point(up direction of steeringwheel).
When it crosses the 0 point it gives the opposite rotation direction once.
I suppose it has to do with the fact that the “prevRotationDegrees” is on the other side of the 0 point.
Is there a solution for this?
This is my implementation:
Vector3 currentRotationVector = transform.localRotation.eulerAngles;
float angle = SignedAngle(prevRotationVector, currentRotationVector, Vector3.up);
if (angle < -30.0F)
{
print("turn left");
prevRotationVector = currentRotationVector;
}
else if (angle > 30.0F)
{
print("turn right");
prevRotationVector = currentRotationVector;
}