• Create Account

Need scary sound effects or creepy audio loops for your next horror-themed game? Check out Highscore Vol.3 - The Horror Edition in our marketplace. 50 sounds and 10 loops for only \$9.99!

# How to handle keyboard input in racing games

Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

5 replies to this topic

### #1kravibom  Members   -  Reputation: 108

Like
0Likes
Like

Posted 02 October 2013 - 07:47 AM

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.

### #2Álvaro  Crossbones+   -  Reputation: 7938

Like
2Likes
Like

Posted 02 October 2013 - 10:03 AM

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.

### #3brunopava  Members   -  Reputation: 263

Like
1Likes
Like

Posted 02 October 2013 - 12:38 PM

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.

### #4kravibom  Members   -  Reputation: 108

Like
0Likes
Like

Posted 04 October 2013 - 12:09 AM

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.

### #5Hodgman  Moderators   -  Reputation: 19220

Like
2Likes
Like

Posted 04 October 2013 - 12:31 AM

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, 04 October 2013 - 07:32 AM.

### #6LorenzoGatti  Crossbones+   -  Reputation: 1980

Like
0Likes
Like

Posted 04 October 2013 - 01:51 AM

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.
Produci, consuma, crepa

Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

PARTNERS