Acelerometer position at star?

Hi,

I am trying to calibrate the accelerometer regarding the iphone position. I am using the StarTrooper script to set the orientation of one ship.
I have adjusted the code to get the accelerometer.input and adjust the ship orientation according but it is not working. I mean i cannot tilt the ship up, it only works right, left, and down.

any help will be appreciated.

This is the script

var turnSpeed : float = 10.0;
var maxTurnLean : float = 50.0;
var maxTilt : float = 50.0;

var sensitivity : float = 10.0;

var forwardForce : float = 1.0;
var guiSpeedElement : Transform;

private var normalizedSpeed : float = 0.5;
private var euler : Vector3 = Vector3.zero;

var horizontalOrientation : boolean = true;

private var isControllable : boolean = true;

private var accelCalib : Vector3 = Vector3.zero;

function Awake () {
    if (horizontalOrientation){
        Screen.SetResolution(480, 320, true);
        Debug.Log("SpaceCraftController.js : horizontalOrientation=true");
    }
    else
    {
        Screen.SetResolution(320, 480, true);
        Debug.Log("SpaceCraftController.js : horizontalOrientation=false");

    }

    guiSpeedElement.position = new Vector3 (0, normalizedSpeed, 0);
   

}

function Start(){
    accelCalib.x = iPhoneInput.acceleration.x;
    accelCalib.y = iPhoneInput.acceleration.y;
    accelCalib.z = iPhoneInput.acceleration.z;
   
}

function Update () {
    if (GameController.isRunning  isControllable){
        for (var evt : iPhoneTouch in iPhoneInput.touches)
        {
            if (evt.phase == iPhoneTouchPhase.Moved)
            {
                normalizedSpeed = evt.position.y / Screen.height;
                guiSpeedElement.position = new Vector3 (0, normalizedSpeed, 0);
            }
        }
    }
}


function FixedUpdate () {
   
    if (GameController.isRunning  isControllable) {   
        rigidbody.AddRelativeForce(0, 0, normalizedSpeed * forwardForce);
   
        var accelerator : Vector3 = iPhoneInput.acceleration;

        if (horizontalOrientation)
        {
            //Debug.Log("SpaceCraftController.js : horizontalOrientation");
            var t : float = accelerator.x;
            accelerator.x = -accelerator.y - accelCalib.y;
            accelerator.y = t - accelCalib.x ;
           
        }
   
        // Rotate turn based on acceleration       

        euler.y += accelerator.x  * turnSpeed;

        // Since we set absolute lean position, do some extra smoothing on it

        euler.z = Mathf.Lerp(euler.z, -accelerator.x * maxTurnLean, 0.2);

        // Since we set absolute lean position, do some extra smoothing on it

        euler.x = Mathf.Lerp(euler.x, accelerator.y  * maxTilt, 0.2);
   
        // Apply rotation and apply some smoothing
        var rot : Quaternion = Quaternion.Euler(euler);
        transform.rotation = Quaternion.Lerp (transform.rotation, rot, sensitivity);
    }
}

Look here!

http://forum.unity3d.com/viewtopic.php?t=15684

Don’t forget keyword searches in the forum or google the forum to get what you need!