Accelerometer script bug

Hi,

Create a sphere, make the camera look down and apply this script to the sphere. The sphere moves according to the iPhone movement. The problem is that it keeps moving even if the iPhone doesn’t… What am I doing wrong? I tried it without the iPhone connected to the computer and it still moves…

Thanks,

Robert

	// make portrait view
	iPhoneSettings.verticalOrientation = false;

function FixedUpdate () {
	var dir : Vector3 = Vector3.zero;

		dir.x = -iPhoneInput.acceleration.y;
		dir.z = iPhoneInput.acceleration.x;
		
transform.Translate (dir.x, 0, dir.z);	
}

The phone will detect and register acceleration even if the phone is held motionless. Imagine, you are held to the ground by a constant accelerating force called gravity, just because you’re not moving doesn’t mean it’s not there. So your ball feels that gravity too, and if you hold the phone, even at a slight angle, that gravity may very well trigger movement by your ball.

The problem is that even if the iPhone is not connected to the Mac (Remote) it still moves… where does it get the information then?

If you’re running the Unity Remote application then that connects to Unity authoring via a wireless connection so tethering isn’t used. Also, IIRC it may just be that without the device attached it’s got some sort of cached “last value” it’s using in lieu of ongoing input? Either way, what does that matter as it really only matters what happens when input is being received, right?

(although if that is happening then get a bug logged just for sanity’s sake)