Actually, its not handling like, the way,it does in any professional racing game. What I think, really is the problem, is car’s turning fine at slow speeds, upto 50 mph, but afterwards, a little input,causes it to be steered more and this happens very quickly and it’s out of control at this time.
@andrea85cs :
Thanks mate, but, I think, the code has some problems, car ,once steered, stays steered, even after release of input, although , we can steer it to opposite direction .But it stays there,even after the release of input.
After a detailed search, I collected a few points, like center of mass needs to be tweaked, so,to get , the right feel on the car. If center of gravity is left shifted a little on high speed right hand cornering n’ like that, this way, we can control the weight distribution .On brakes weight needs to on front end, and on acceleration, it should behind ,the on rest, center of gravity(ie., in rear end) .I hope this is how it needs to be done. I am about to try it.Wish me luck
Have a high speed steering angle and a low speed steering angle. Then, use Mathf.Lerp to vary between them depending on the car’s speed:-
var highSpeedSteer = 20.0;
var lowSpeedSteer = 45.0;
var highSpeedLevel = 50;
function Update() {
var fwdSpeed = rigidbody.velocity.magnitude;
var highSpeedFraction = fwdSpeed / highSpeedLevel;
var actualSteerAngle = Mathf.Lerp(lowSpeedSteer, highSpeedSteer, highSpeedFraction);
... steering code based on actualSteerAngle ...
}
When you drive a real car and go really fast, you turn the steering wheel up to a few degrees. When going slowly, up to 900 degrees can be used. The hard part is to let a driver of your game turn the wheels pressing keyboard keys for certain amounts of time. There is no universal solution to this but andeeees solution should work very well, but then it is not possible to turn the wheels a lot in high speed, no matter how long you keep the button pressed. I recommend that you change the sensitivity and gravity of the Input, based on vehicle speed.
Another thing… You say that the vehicle turns unnaturally in high speeds. Maybe your tires should have less lateral traction.
// 50 is the max velocity
private var highSpeedFactor : float = 1.0 / 50.0;
function FixedUpdate() {
var fwdSpeed = transform.InverseTransformDirection(rigidbody.velocity);
// I'm presuming that z is car forward.
var highSpeedFwd = fwdSpeed.z * highSpeedFactor;
var steerVel = 1 - Mathf.Clamp01(highSpeedFwd);
... (steerVel * steer * steerSpeed * Time.deltaTime)...
....
Sorry about the late reply, but . . . . .I tried all those techniques…but nothing seems to be so good .Can you tell me, any tutorial with perfect handling, with/without wheel colliders ,something as good as HelloRacer .