# GearVR detect wheather the controller has been rotated left or right

Posts: 3
NerveGear
I'm trying to rotate my car with Gear VR controller to left and right. I've somehow found that the rotations are from Y-axis are b/w 270-360 & 0-90 with enough play testing(Debugging). But, I'm sure it's ugly code.

**Question**

How can I get the rotation values and how do I map them b/w (1)-(0)-(-1) so I can assign them to my `CarController`.

**Logic I've implemented** [![Image][1]][1]

I'm converted values 270 to 359 in 0 to -90 than dividing them by -90 to map them from 0 to -1

private CarController m_car;

// Use this for initialization
void Start () {
m_car = GetComponent<CarController>();
}

// Update is called once per frame
void FixedUpdate () {

OVRInput.FixedUpdate();
float angle = 0;

if (((OVRInput.GetLocalControllerRotation(OVRInput.Controller.RTrackedRemote).eulerAngles.y >= 270 &&
OVRInput.GetLocalControllerRotation(OVRInput.Controller.RTrackedRemote).eulerAngles.y <= 359)) ||
((OVRInput.GetLocalControllerRotation(OVRInput.Controller.RTrackedRemote).eulerAngles.y <= 90 &&
OVRInput.GetLocalControllerRotation(OVRInput.Controller.RTrackedRemote).eulerAngles.y >= 0)))
{
float rotationValue = OVRInput.GetLocalControllerRotation(OVRInput.Controller.RTrackedRemote).eulerAngles.y;

// if the value is 3 digit than subtract it from 360 and make it negative
if (Mathf.Floor(Mathf.Log10(rotationValue) + 1) == 3)
{
rotationValue -= 360f;
}
rotationValue /= 90f;

angle = rotationValue;
}

float torque = 0;

if (OVRInput.Get(OVRInput.Button.One))
{
torque = -1;
}
if (OVRInput.Get(OVRInput.Button.PrimaryIndexTrigger))
{
torque = 1;
}

m_car.Move(angle, torque, torque, 0f);
}
}

> BUG: It works right sometimes but it doesn't work sometimes. Sometimes I get different angles & car movement looks buggy(only moves right). So my logic fails

Tagged: