我的游戏中的音乐会干扰加速计值。怎么解决这个问题呢?
我正在编写一款游戏,玩家可以倾斜手机来控制角色。
问题是:音乐(大声播放时)和声音效果(如枪声)会干扰加速度计值。这会导致奇怪的角色运动。
请给我一些关于如何解决这个问题的建议。
先感谢您!
I'm writing a game where the player tilt the phone to control a character.
The problem is: the music(when playing loud) and sound effect(like gun shots) disturbs the accelerometer values. This result in weird character movement.
Please give me some advice on how to solve this.
Thank you in advance!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
也许您需要调整应用程序对加速度计数据的敏感度?听起来你甚至让最轻微的动作都会引起角色的动作。您能否增加“噪音”阈值,使它们必须稍微倾斜一点才能让角色移动,但不让声音振动调整动作?
换句话说,如果加速度计相对于静止位置/最后有效加速度计读数的变化增量大于某个阈值,则接受新的加速度计读数。
Perhaps you need to adjust the sensitivity of your app to the accelerometer data? It sounds like you are letting even the slightest movements cause character movements. Can you increase the "noise" threshold such that they have to tilt just a little bit more to get the character to move but not let sound vibrations adjust movements?
In other words, if the delta of the accelerometer change from resting position/last valid accelerometer reading is greater than some threshold value, then accept the new accelerometer reading.