I have an accelerometer script that works great in portrait mode.
Tilt forward = move forwards Tilt back = move back Tilt left = move left Tilt right = move right
all good!
Now I changed things up a bit by forcing player into Landscape mode... I now have the device horizontal with button on right side. This is the mode I want to develop the game for...but the accelerometer script is now confusing me Im not sure how to modify it.
Now I get this from this slightly modified script:
Tilt forwards = move forwards ( ok! ) Tilt back = move backwards ( great! ) Tilt right = goes up?? Tilt left = goes down??
Im not really looking for Y acceleration...I think Im looking for Z rotation?? how do I find this?
How do I get this to:
Tilt right = goes right. Tilt left = goes left.
using UnityEngine;
using System.Collections;
public class NewBehaviourScript : MonoBehaviour {
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
if ( Application.platform == RuntimePlatform.IPhonePlayer )
{
float z = iPhoneInput.acceleration.z * -1;
transform.Translate(0,0,z*8);
float y = iPhoneInput.acceleration.y; // should i get some rotation?
transform.Translate(0,y*8,0);
}
else
{
float z = Input.GetAxis("Vertical");
float x = Input.GetAxis("Horizontal");
transform.Translate(0,0,z);
transform.Translate(x,0,0);
}
}
}