- Home /
Question by
hgaur725 · Jan 07, 2016 at 10:26 PM ·
androidaccelerometer
Accelerometer Help?
void Update()
{
Vector3 dir = Vector3.zero;
dir.x = Input.acceleration.x;
dir.y = Input.acceleration.y;
if (dir.sqrMagnitude > 1)
dir.Normalize();
dir *= Time.deltaTime;
transform.Translate(dir * speed);
}
Hey Folks i am using accelerometer in my game for android and i am using this code for the movement, although this is working but it is still not moving player smoothly on device.i had applied this script on the player which is just a 2d sprite and player having collider ont it no rigidbody. so can any body tell me how can i smoothly move the player any addition in this code or new thanks !!
Comment
Add this line of code in Start method.
Application.targetFrameRate = 60
Your answer
Follow this Question
Related Questions
Player Movement when phone shakes 0 Answers
Rotate Camera using Accelerometer 0 Answers
receive upd packet from android and show visualization 0 Answers
Android Tilt controls help 1 Answer