Hello,
I'm searching for a more convenient way to handle the steering control and horizon screen tilt.
At the moment I'm using this function as the base for my car steering:
public static float RotationYXAngle180Degree(Vector3 currentAcc)
{
float rotationAngle = Mathf.Rad2Deg * Mathf.Atan2(currentAcc.y, currentAcc.x);
return rotationAngle;
}
For the screen horizon tilt I'm using as the base this function:
public static float RotationYXAngle360Degree(Vector3 currentAcc)
{
float rotationAngle = Mathf.Rad2Deg * Mathf.Atan2(currentAcc.y, currentAcc.x);
if (rotationAngle < 0f)
rotationAngle = rotationAngle + 360.0f;
return rotationAngle;
}
The Vectors are calibrated with an 4x4 Matrix. Here arises already a part of my problem. If I play the game lying on my back then the screen is tilt 180 degree in the wrong direction and the car will steer the wrong way. I tried before to use only the accelerometers Y axis, It just didn't respond well.
A new solution or direction to my problem is greatly welcome ;-).
Peter.