Accelerometer smoothing

This is my code for a block to move with the accelerometer, but it think its not smooth enough, how could i change it?

void MoveLeft ()
    {
        transform.Translate(Vector3.left * Time.deltaTime * VelocityCube, Space.World);
    }

    void MoveRight ()
    {
        transform.Translate(Vector3.right * Time.deltaTime * VelocityCube, Space.World);
    }

    void Accelerometer ()
    {
        float x = Input.acceleration.x;
        if (x < -0.1f) {
            MoveLeft ();
        } else if (x > 0.1f) {
            MoveRight ();
        }
    }

    void FixedUpdate ()
    {
        Accelerometer ();
    }

Put it in Update rather than FixedUpdate. FixedUpdate should be used exclusively for physics calls.
e.g. everything that has to do with adding force to rigidbodies.

1 Like