Hey guys,
I am using following script to move my Player by tilting the phone:
void FixedUpdate ()
{
tiltAcceleration = Vector3.zero;
tiltAcceleration.x = Input.acceleration.x;
if (tiltAcceleration.sqrMagnitude > 1)
tiltAcceleration.Normalize();
tiltAcceleration *= Time.deltaTime;
transform.Translate (tiltAcceleration * sideSpeed);
// This is how I try to limit my velocity of Player, but it DOES NOT WORK!
playerRigidbody.velocity = Vector3.ClampMagnitude (playerRigidbody.velocity, 5f);
}
In the code above, you can see at the last line, how I am tryint to limit my velocity while tilting the phone - however, this does not work, it still moves too fast, so it passes the Box Colliders (side-walls).
I have read few answers here on Unity, but noone helped in my case.
Any advice appreciated.