Hey guys I was looking at the accelerometer tutorial that Unity made.
I’ve been trying to understand how to limit the speed. Right now it shoots off at a thousand miles per hour if I tilt it more than a centimeter.
There’s no much to look at, but I’m only wanting to use the accelerometer for the X axis.
Here is the basic code that I have.
public class Controls : MonoBehaviour {
// Variables dealing with Speed and boost.
public float speed;
public int sideSpeed = 1.0;
void Start(){
}
// Update is called once per frame
void Update () {
//Use this for constant forward movement
transform.Translate (Vector3.forward * speed * Time.deltaTime);
//Use this for the accelerometer for X Axis.
transform.Translate (Input.acceleration.x, 0, 0 * sideSpeed * Time.deltaTime);
}
}
I’ve tried doing it with Addforce, but even if I change the force to 50000 it just moves in slowmotion.
I’ve seen stuff about clamps, but I don’t understand the clamping for this.
I’m new to mobile development.
Please help me.
Thank you!