This seems to work well but I can't figure out how to drive backwards now. Stuck. But so far it's doing precisely what I needed. As soon as the angle of attack increases I use a secondary key to change gears (fake gearbox) and as soon the slope ends, I get back to the initial speed and the vehicle won't just jump over the edge.
rigidbody.drag = rigidbody.velocity.magnitude / 1000;
float angle = 0.0f;
Vector3 axis = Vector3.zero;
rigidbody.rotation.ToAngleAxis(out angle, out axis);
float _x_angle = Mathf.Abs(angle*axis.x);
_x_angle = Mathf.Clamp( _x_angle, 0f, 10f);
acc = Mathf.Lerp(accSlope, accAngle, _x_angle/10f );
↧