- Home /
accelometer problem
The following code is supposed to move object on z axis dependently of iPad's movement forward and backward (not rotation) in landscape (home button is on right) And problem is that object moves precise and smootly enought when device is being rotated on x axis, but when iPad is moved forward and backward (no rotation) object moves very disobedient and sometimes even not on movement direction.
function MoveObject()
{
var dir : Vector3 = Vector3.zero;
dir.z = Input.acceleration.x;
if (dir.sqrMagnitude > 1)
dir.Normalize();
dir *= Time.deltaTime;
transform.Translate (dir * speed);
}
Thanks for support!
This code is too simplistic. You need to use the direction of gravity to measure tilt. You're going to need to incorporate quaternions into this.
Your answer
Follow this Question
Related Questions
Why is the Gyroscope inverted? 0 Answers
Constant Input.Accelerometer Updater for Mobile? 0 Answers
New Gyroscope Controls in Unity 4? 2 Answers
iOS Compass over Unity Remote 5 0 Answers
Accelerometer input working in Unity Remote, not working in build. 1 Answer