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.