How to handle keyboard input in racing games

This topic is 2117 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

Recommended Posts

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.

Share on other sites

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.

Share on other sites

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.

Share on other sites

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.

Edited by Hodgman

Share on other sites
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.

• 18
• 29
• 11
• 23
• 16