Drifting tilt controls

Hello,
I’m hoping someone can help / suggest a work around.
I’m having a problem with my tilt control for a game I’m working on. I’m basically using the tilt control to rotate around a fixed point (think Tempest).
I’m using the basic code from the docs (just slightly modified):-

function Start () {
var dir: Vector3 = Input.acceleration;
}

function Update () {
var dir : Vector3 = Vector3.zero;
var tiltConOffSet = SetTiltControl.tiltOffSet;//Static Tilt control Value
dir.z = -Input.acceleration.y + (tiltConOffSet * -1);

// clamp acceleration vector to unit sphere
if (dir.sqrMagnitude > 1)
dir.Normalize();

dir = dir* runningBackward; //Should invert the controls
dir *= Time.deltaTime;

// Move object
transform.Rotate (Vector3.forward + (dir * speed));
}

Basically I get the tilt value of the control at the start of the game and use this as an offset (tiltConOffSet) to calibrate the iPhone (that bit works as I have tried it at extreme angles), but the problem is that there’s always a slight drift to the right (about 5 deg. a second so it’s very noticeable).
My guess is because I’m multiply the value by speed (currently set to 250), theres a slight, but constant variation and because it’s getting multiplied by the speed value, it shows a lot more.
I’ve reduced the speed value and the drift is also reduced, but it also makes the game unplayable as the player hardly moves.
Can any one suggest away around this and ideally in simple terms as I’m not much of a programmer at the moment (but I’m getting better slowly).

Thanks in advance,
Mike.

Another option for this might be to limit the float value of the angle to a set number of decimal places. I know it would mean losing some of the finer control of the game, but it might be better then the constant drifting off to the right.
Does anyone know how to do this? Basically been able to limit a float to X decimal places?

Thanks,
Mike.

To limit a float to a certain number of decimal places, multiply it by that number of decimal places, round it to an integer, then divide it by the same number of places. For example, to limit to three dp:-

numToLimit = Mathf.Round(numToLimit * 1000) / 1000.0;

Of course!! Why didn’t I think of that.
Thanks again for your help.

Mike.