# How to get Steering Wheel Rotation angle?

Hi Everyone!
I want to get a steering wheel rotation angle, to aply it on car rotation.

But I’m Using EulerAngles, and it’s returns only 360 type angle, without negative angles. I tried to get negative, and it works, but only from 0 to -180, and from 0 to 180.

How can I register , for example, a 720 negative rotation?

Thank you!

``````public float SteeringWheelAngle;
// Use this for initialization
void Start () {

}

// Update is called once per frame
void Update () {
SteeringWheelAngle = transform.localEulerAngles.y;
SteeringWheelAngle = (SteeringWheelAngle > 180) ? SteeringWheelAngle - 360 : SteeringWheelAngle;

}
``````

one way is to track the previous value and handle the case where it wraps around.

``````private float _syntheticAngle = float.NaN;
private float _prevAngle      = float.NaN;

// Update is called once per frame
void Update () {
SteeringWheelAngle = transform.localEulerAngles.y;
SteeringWheelAngle = (SteeringWheelAngle > 180) ? SteeringWheelAngle - 360 : SteeringWheelAngle;

if (float.isNan(_syntheticAngle)) {
_syntheticAngle = SteeringWheelAngle;
_prevAngle      = SteeringWheelAngle;
}

float dAngle = SteeringWheelAngle - _prevAngle;

if (dAngle < -180) {
// eg it hopped from -170 to +170
dAngle += 360;
}
else if (dAngle > 180) {
// eg it hopped from +170 to -170
dAngle -= 360;
}

_syntheticAngle += dAngle;
}
``````