- Home /
Flat and Incline Tilting Controls
I'm unsure about how I should go about this or what term I should exactly used to get a successful search but so far I have no luck. I have the following as my controls for moving the player by tilting the phone.
Vector3 dir = Vector3.zero;
dir.x = Input.acceleration.x;
dir.y = Input.acceleration.y;
if (dir.sqrMagnitude > 0)
{
dir.Normalize();
}
dir *= Time.deltaTime * speed;
transform.Translate(dir);
float angle = Mathf.Atan2(dir.y, dir.x) * Mathf.Rad2Deg;
spritePlayer.transform.eulerAngles = new Vector3(0, 0, angle - 90);
My question is, how can I calibrate / make it possible for the player to have the phone either flat and play the game with the tilting controls and have it inline (holding up facing them) and have the tilting control work based off where there phone is when the game start so that when the hold it up in front of them the tilt control is not pointing down. Kind of like Hyperlight.
Your answer
Follow this Question
Related Questions
Android creation 2 Answers
Tilting ball with acceleration in 2D for android 0 Answers
gui and tilt function 1 Answer
When export in Google Android Project, can I add activity ? 0 Answers