- Home /
Input.acceleration reading Issue
Hey there, I am experimenting with the tilting controls on mobile and came across with a problem.
The PlayTest level is below. When the ball is rolling on the ground everything works fine, even while jumping. The issue comes when it touches a wall. The movement gets sloppy and the calibration changes for some reason.
As an example, if the ball touches a wall that is facing the camera, tilting the device forward will move the ball backwards.
The code I am using is pretty default, as I copied its core:
(JavaScript)
function Update ()
{
var dir : Vector3 = Vector3.zero;
dir*= Time.deltaTime;
dir.x = 0.25*Input.acceleration.x;
dir.z = 0.25*Input.acceleration.y;
transform.Translate(dir.x, 0, dir.z);
}
Any idea on why this happens /how to fix this?
Answer by LeBesta · Aug 05, 2017 at 03:21 AM
UpDate: Seems like the problem is actually with transform.Translate
Fixed the problem by using forces to move the ball and still using Input.acceleration to input the directions
Your answer
Follow this Question
Related Questions
iPad: accelerator tilt breaks collider 3 Answers
Smooth tilt accelerometer 1 Answer
Moving object with tilting the device. 1 Answer