- Home /
This post has been wikified, any user with enough reputation can edit it.
Question by
hariszaman · Jul 05, 2013 at 10:10 AM ·
charactercontrolleraccelerometerruntilt
tilt not working
hi I am using the following to apply tilt to my player which is a charactercontroller but this has a problem that when I shake my phone the player start shaking as well along with the camera. I just want my player to ignore this shake so that the tilt can look much smoother basically I want it to be same like temple run.Any help would be greatly appreciated
void Update () { controller.Move(transform.forward speed Time.deltaTime);
accel = Vector3.Lerp(accel, Input.acceleration, filter* Time.deltaTime);
Vector3 dir;
dir = new Vector3(accel.x, 0,0);
// limit dir vector to magnitude 1:
if (dir.sqrMagnitude > 1)
{
dir.Normalize();
}
transform.position = new Vector3(Mathf.Clamp( dir.x *1.5f ,-1.5f,1.5f ), transform.position.y , transform.position.z);
}
Comment
Your answer
Follow this Question
Related Questions
How to create tilt control similar to temple run? 0 Answers
How i can make a running button? 0 Answers
shoot in direction of tilt 0 Answers
Rigidbody2D with Accelerometer 0 Answers
input.acceleration - change the zero position of the phone? 0 Answers