- Home /
Question by
EaswarChinraj · Nov 02, 2020 at 08:35 AM ·
movementtransforminputmobile
Problem in player movement using accelerometer input
I am designing an endless runner style game like temple run. I need to move the player left and right based on the accelerometer input (tilting). The problem is that the accelerometer input is very sensitive. In other words the player is moving left even if the phone is hold straight. I want to make the player to move smoothly like temple run game. (Player has a Rigidbody component attached to him.). Here is what I have done so far:
if (Input.acceleration.x < 0)
{
this.transform.Translate(-0.3f, 0, 0);
}
else if (Input.acceleration.x > 0)
{
this.transform.Translate(-0.3f, 0, 0);
}
I tried comparing Input.acceleration.x is greater than 0.2 and -0.2, 0.1, -0.1.
What am I doing wrong here? Please help me.
Comment
Your answer
Follow this Question
Related Questions
[SOLVED] Object keeps sliding? 2 Answers
controle of an gameobject 1 Answer
How to make responsive Touch inputs? 1 Answer
Code Not Working 1 Answer