moving an object with accelerometer using unity iphone.

Hello guys, I am pretty new with unity iPhone and i have to move an object with accelerometer. i have been goggling around for some tutorial but i have not got any. used the script of roll-a-ball example but that is not working as well.

if anyone can share a tutorial or some example of moving an object using accelerometer then i would be a great help.

thanks in advance.

from the script reference::

// Move object using accelerometer
var speed = 10.0;

function Update () {
var dir : Vector3 =;

// we assume that device is held parallel to the ground
// and Home button is in the right hand

// remap device acceleration axis to game coordinates:
// 1) XY plane of the device is mapped onto XZ plane
// 2) rotated 90 degrees around Y axis
dir.x = -Input.acceleration.y;
dir.z = Input.acceleration.x;

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

// Make it move 10 meters per second instead of 10 meters per frame...
dir *= Time.deltaTime;

// Move object
transform.Translate (dir * speed);

In Unity 4.1 is not working. Any solution? When I compile in 3.5 has no problems, but I made a stupid opening my project in Unity 4.1 and I have to finish the game on it. Someone has the same difficulty?