Accelerometer working in environment, not working in build

Hello all,

We’re having a weird problem with iPhone development (that’s a switch, right?) For some reason, when testing in Unity, the accelerometer functions fine. However, when we do a build, the accelerometer doesn’t work at all in the build version.

Anyone have any idea why this would occur?

using UnityEngine;
using System.Collections;
public class PlayerScript : MonoBehaviour {
	Vector3 iPhoneAcc;
	void FixedUpdate () 
	{		
		iPhoneAcc = iPhoneInput.acceleration;
		Debug.Log("X:"+iPhoneAcc[0].ToString() + "  Y:"+iPhoneAcc[1].ToString() + "  Z:"+iPhoneAcc[2].ToString());
	}
}

I realize this is probably not documented (maybe it is, but I don’t have documentation to show it or say where it is) anyway this is C# script, i have seen others ask about how to get this information, so here it is.

You should see the output of the values in your Unity Console.
It is probably working however, your movement time scale is different in the editor vs live.

An example of use of this to test on the iPhone itself, this is if your game is based on landscape mode or:

iPhoneSettings.verticalOrientation=false;

Elsewhere in your class:

	float fieldLeft;
	float fieldRight;
        Vector3 pPos;
	void movePlayer()
	{
		transform.Translate(Vector3.right * -iPhoneAcc[1] * 40 * Time.deltaTime); 
		pPos = transform.position; 
		pPos[0] = Mathf.Clamp(transform.position.x, fieldLeft, fieldRight); 
		transform.position = pPos; 	
	}

In Unity I would have the scale set to 10 or 20, but on the iPhone to get the same speed I set it to 40.

Sadly all the docs have to say about it:
file://localhost/Applications/Unity%20iPhone/Unity%20iPhone.app/Contents/Documentation/Documentation/ScriptReference/iPhoneAccelerationEvent-acceleration.html

Which is simply uber descriptive:
iPhoneAccelerationEvent.acceleration

var acceleration : Vector3
Description

Value of acceleration

It doesn’t go into the values and orientation of the iPhone nor does it go into the difference between the speed values of the Editor vs the Phone itself, some discovery is needed based on your phone type. Docs need major overhaul. I browse to them directly under my Unity iPhone folder, my help within the editor keeps bouncing me to regular unity docs so just browsing to the file and opening it works.

Just use the debug print output and look at XCode console output and you will see the debug values there also.