unity3d - Accelerometer sensitivity

二次信任 提交于 2019-12-04 14:14:57

You may need to use a low pass filter (s. Exponential Moving Average for a better description regarding software) before using the signal output. I always use native code to get accelerometer and gyroscope values on iPhone so I am not 100% sure how Unity handles this. But from what you are describing the values appear unfiltered.

A low pass filter calculate a weighted average from all your previous values. Having for example a filter factor on 0.1 your weighted average is:

Vector3 aNew = Input.acceleration;
a = 0.1 * aNew + 0.9 + a;

This way your values are smoothed at the expense of a small delay. Running the accelerometer with 50 Hz you won't notice it.

I couldn't make Kay's example work as it was not multiplying the last part, so here's my small correction:

Vector3 aNew = Input.acceleration;
a = (0.1 * aNew) + (0.9 * a);
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!