How to handle keyboard input in racing games

Started by
4 comments, last by LorenzoGatti 10 years, 6 months ago

Planning on creating a racing game with intense turning, drifting elements. Was wondering how to handle wheels turning angle from keyboard with its digital input. Anyone have some ideas on this one: http://www.carx-tech.com/webplayer/webplayer.html

I guess it's more then just speed dependant.

Advertisement

I would just start with something simple and play around with it. That something simple could be something like interpreting the input as an angular velocity applied to the steering wheel. Cap the position of the steering wheel to make sure it stays within [-MaxAngle,+MaxAngle], and add a restitution of some sort when the keys are released.

Test this scheme at a fixed, typical speed, then see if it needs any dependence on the speed.

Check this out:

http://u3d.as/content/unity-technologies/car-tutorial/1qU

With a few tweeks I think you can manage to do what you want.

I would just start with something simple and play around with it. That something simple could be something like interpreting the input as an angular velocity applied to the steering wheel. Cap the position of the steering wheel to make sure it stays within [-MaxAngle,+MaxAngle], and add a restitution of some sort when the keys are released.

Test this scheme at a fixed, typical speed, then see if it needs any dependence on the speed.

Well, some actual car manufacturers implements sort of steering wheel sens. reduction with speed. That is done for not allowing car to flip or went out of control on speed turns.

I'm happy how car behaves in turns with no aids. But it's getting pretty messy when it trying to, say, change the lane on highspeed. The project I'm working on have pacejka implementation for wheels. I've talked to some experts, they suggest to find wheel's perfectgrip angle (where grip at it's top) and since then, if the speed more then some variable, apply a small amount of steer to wheels.

The carx one will be based on something similar to traction control, where it will evaluate the amount of slip/grip from the actual tire physics simulation (ask pacejka what the optimal slip angle is) and determine a which angle the tires will completely lose traction. The steering controller will then choose to limit you so you don't turn past this angle, and that grip/control is maintained.

You can also model centrifugal force pushing the steering wheel back to neutral, with the effect that (for the same left or right button press) the curvature of the trajectory increases fastest when you are going straight. Somewhat complex formulas involving grip and car orientation might be needed to do a really good job, but if you want to include drifting you are expected to deal with such factors anyway.

Omae Wa Mou Shindeiru

This topic is closed to new replies.

Advertisement