- Home /
Hey guys, could anyone please help me with a platform game I am working on. The player goes left and right like doodle jump. It does work just not very smoothly. Thanks :)
public class PlayerMove : MonoBehaviour { /*public float speed = 25f;
void Update()
{
float temp = Input.acceleration.x;
transform.Translate(temp * speed * Time.deltaTime, 0, 0 );
} */
Answer by Captain_Pineapple · Apr 23, 2018 at 07:23 AM
It might help to use:
Input.GetAxis("Horizontal");
Instead of:
Input.acceleration.x;
In case you want to have a even smoother speed transition you should store the current speed in some variable curSpeed and then use:
Mathf.Lerp(curSpeed,Input.GetAxis("Horizontal")*speed,0.4f);
The last argument can take values between 0.0f and 1.0f and will determin the speed with wich your speed converges to the current value given Input*speed;
Thank you, just added the $$anonymous$$ath.Lerp and it made it a lot smoother.
Your answer
Follow this Question
Related Questions
GameObject dosen't move 2 Answers
how to make the sprite and the background color in a tile disappear? 0 Answers
How to calibrate my accelerometer? (available options not working) 0 Answers
Admob works on an empty project but not on my actual project 0 Answers
How to Display high score using GUIText 0 Answers