Transformation movement by using Accelerometer data

Is It possible to make transformation movement by using Accelerometer data or Accel + Gyro ?
as we know, we can make rotation by using Accel or Gyro data.
However, how can we make transformation movement?
I know this is still problematic and experimental. but there must be some ways to reach.

Is there any algorithm or math formula solving this problem?

Nothing prebuilt that I am aware of, but sure it can be done. Just treat it like you would a horizontal/vertical axis. You’ll want to tweak it until it feels right. On games that I have seen use it, they typically have a “calibrate” option so the user can set what is “up”. Otherwise they have to hold the device flat.

1 Like

Do you think accelerometer calibration can solve the problem?

Player in the scene should be parallel moving with my smartphone sensor.

I still don’t understand what you are trying to do here, but maybe this will accomplish it, untested:

private Vector3 accelerationAVG        = Vector3.zero;
  
void Update(){
    float avgFac = 0.08F;
    accelerationAVG += (Input.acceleration - accelerationAVG) * avgFac;
    Vector3 usedVector = accelerationAVG;

    float speed = 0.05F;
    myTransform.position += new Vector3(usedVector.x, 0F, usedVector.z)* speed
}
1 Like

the code above did not show result which is what I want.

If I move my smart Phone in x-Axis, object should follow smart phone dirction (object should move in x-Axis too)
I am not gonna tilt or rotate my smartPhone, I am gonna move my smartphone in one Axis (x or y or z)

Did you understand?

Oh, I thought you meant to use it like a control stick. Actual directional control may be trickier, especially on general devices. The Tango has direct support for stuff like that. Not sure the best way to handle it on other devices.

1 Like

Only tango devices are capable of doing this because of special hardware?

If I create project like transformation movement using accelerometer in unity, this project is run in only Tango devices?

Unity does not operate at fixed framerate, so using 0.05f for time scale will result in different movement speed on different devices.

Precise rotational tracking requires a gyroscope. A lot of devices do not have them. In this case some applicaitons (such as google sky) fall back to using compass instead, but precision is not that great.