Steering vehicles with cursor keys

Discussion in 'Game Development (Technical)' started by jefferytitan, Sep 9, 2009.

  1. jefferytitan

    Original Member

    Joined:
    Apr 22, 2006
    Messages:
    364
    Likes Received:
    1
    Hey people,

    I'm working on a project in Unity, it involves truck driving. Has anybody got any idea on how to steer intuitively with cursor keys? The problem is the binary nature of pressing keys.

    I imagine that you might model it as applying a velocity/acceleration combo to an imaginary steering wheel. A base turning speed plus an acceleration the further the wheel has turned. The wheel should also return to neutral after some period of not pressing any keys. Of course there would also be the full lock limitation. Perhaps two designer-tweakable curves, one for the velocity to apply per current wheel position when the key is down, and another for when the key is up? Also would you reduce the effect of steering on the wheels when travelling at high speed to make it easier to control?

    If anybody has steering experience for anything, racing cars, boats, etc it may be helpful.

    Cheers,

    JT
     
  2. Applewood

    Moderator Original Member Indie Author

    Joined:
    Jul 29, 2004
    Messages:
    3,859
    Likes Received:
    2
    We did the simulated steering wheel method on Carmageddon and it worked fairly well.

    In fact iirc what we actually did was encapsulate the keyboard so that keys could be treated the same as console buttons with actual analog inputs, and faked that on digital keys by increasing their down strength over time. (Then implemented a GetAnalog() for all keys.

    Don't overdo it though, you want light taps to actually achieve something as that's how players tend to "drive" ime.
     
  3. Dyno Kid

    Indie Author

    Joined:
    Aug 10, 2006
    Messages:
    553
    Likes Received:
    0
    I found this a while ago...hope it helps.

    Darren.
     
  4. Jim Buck

    Indie Author

    Joined:
    Jul 27, 2004
    Messages:
    1,158
    Likes Received:
    0
    I think this is what Applewood is saying, but on some PS1 driving games I did the physics for, I would count up to a max value while the player held down the button. That max value is the equivalent of holding an analog stick/button all the way in a certain direction. When the player lets go of the digital button, the value counts down to 0. How fast/slow it goes to the max and back to 0 is part of the run of tweaking the game to make it feel good to play with digital buttons.
     
  5. jefferytitan

    Original Member

    Joined:
    Apr 22, 2006
    Messages:
    364
    Likes Received:
    1
    Cool, thanks a lot guys. Glad to know I'm on the right track!
     
  6. Pironman

    Pironman New Member

    Joined:
    Mar 27, 2020
    Messages:
    1
    Likes Received:
    0
    Good morning.
    Just 2 question:
    -the time from 0 to max steer is the same from max steer to 0?
    -the steering curve between 0 to max is linear, exponential or something else?

    Thanks
     
  7. gravisxv

    gravisxv New Member

    Joined:
    Feb 26, 2020
    Messages:
    7
    Likes Received:
    1
    probably depends on the type of game your developing. trucks need slower steering curves than sport cars.
     

Share This Page

  • About Indie Gamer

    When the original Dexterity Forums closed in 2004, Indie Gamer was born and a diverse community has grown out of a passion for creating great games. Here you will find over 10 years of in-depth discussion on game design, the business of game development, and marketing/sales. Indie Gamer also provides a friendly place to meet up with other Developers, Artists, Composers and Writers.
  • Buy us a beer!

    Indie Gamer is delicately held together by a single poor bastard who thankfully gets help from various community volunteers. If you frequent this site or have found value in something you've learned here, help keep the site running by donating a few dollars (for beer of course)!

    Sure, I'll Buy You a Beer