Hi everyone.
I’m currently working on an android app, and I’m experiencing some accelerometer related issues.
The game is landscape. I’ve attached this on a camera script
public ScreenOrientation prevScreen = ScreenOrientation.Landscape;
void Update()
{
if ((Screen.orientation != ScreenOrientation.LandscapeLeft) &&
(Screen.orientation != ScreenOrientation.LandscapeRight))
{
Screen.orientation = prevScreen;
}
if ((Input.deviceOrientation == DeviceOrientation.LandscapeLeft) && (Screen.orientation != ScreenOrientation.LandscapeLeft))
{
Screen.orientation = ScreenOrientation.LandscapeLeft;
}
else if ((Input.deviceOrientation == DeviceOrientation.LandscapeRight) && (Screen.orientation != ScreenOrientation.LandscapeRight))
{
Screen.orientation = ScreenOrientation.LandscapeRight;
}
prevScreen = Screen.orientation;
}
And my input is handled like this,
public static float GetHorizontalAxis()
{
float xAxis = -Input.acceleration.y;
xAxisCurrent = xAxis * xAxisModifier;
xAxisCurrent = Mathf.Clamp(xAxisCurrent,-turnClamp,turnClamp);
return xAxisCurrent;
}
This works fine on my droid, an htc wildfire s, and we are currently getting people to test on their devices externally.
We have receved but reports that the turning isnt working properly.
"it doesn’t seem to respond to the G-sensor. It instantly swerves to the left and so the vehicle just goes off the edge of the course. I find that if I tip the tablet completely upside down then it starts to move back to the right, but as soon as I turn it upright, it just goes completely left again.
I’m holding the tablet in landscape mode (i.e. the same as in that main photo on the website), which is how the game starts."
The device hardware is fine, so its not a hardware error.
here is a link to the device http://www.gadgetfreakz.co.uk/tablet-pc/m7-android-2-2-samsung-pv210-cortex-a8-capacitive-7-inch-tablet-flash-10-1-g-sensor-1080p-hdmi-8gb.html
I can’t replicate the bug here, My best guess is that the os reported screen orientation might be the problem if the Input.acceleration is influenced by that.
The controls work by holding the device in a landscape mode, then tilting left and right to steer. They aren’t doing that in this case.
Thanks for your time.