1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
Dismiss Notice
Like RaceDepartment on Facebook.

How to I make a car idle roughly?

Discussion in 'Racer Problems & Fixes' started by iRacer5, Apr 2, 2014.

  1. iRacer5

    iRacer5
    Premium Member

    Hello-

    I am working on a Shelby Cobra 427 and I was wondering if someone knew if there was a way to make it idle roughly.

    Thanks!
     
  2. Look in the car.ini file, there is if I remember correctly, a rumble setting.

    If it's not in the car.ini file check racer.nl documentation.
     
  3. You're right about the rumble settings boomer, for my model A hot rod I set it to:
    Code:
      rumble_amplitude=800
      rumble_maxrpm=2000
      cylinders=4
      cylinder_angle=90  
    I used 4 cylinder's instead of 8 because it shook the car more so how I wanted it (with 8 it barely even moved).
     
    • Like Like x 1
  4. iRacer5

    iRacer5
    Premium Member

    Does this work in 0.655?
     
  5. Wow nice feature, didn't knew it!!! But i can't get it to work...or don't see diference!
     
  6. I've had varied success with this feature.

    I think a rough idle needs to be done a different way though, because the rumble effect is more to do with the un-even torque output of an engine due to the reciprocating nature of the cyclinders and ignition cycles.

    Rumbling idle is more to do with un-even running due to inability to meter air effectively, or injectors that can't operate so perfectly at low duty cycles etc etc.


    I'd probably fudge this with some code like:

    if engine is near idle rpm
    {
    max torque = 1 * random number * factor
    wait (tweakable amount of time)
    }

    That way you can get the fixed throttle idle rpm to chase around the ideal rpm point as the engine torque changes all the time.


    Hmm

    Dave
     
  7. Stereo

    Stereo
    Premium Member

    I don't know if any randomness is necessary, just putting enough of a time delay makes it fairly willing to do its own thing.

    script goes in car\scripts\physics\roughidle.rsx or approximately that:
    Code:
    rcar $car = get scriptowner car
    // inc throttle below idle target
    // dec throttle above idle target
    // off throttle above off target
    float $incthrottle = 0.22
    float $decthrottle = 0.16
    float $offthrottle = 0.02
    float $idletarget = 1600
    float $offtarget = 1800
    // time in milliseconds
    int $checktime = 250
    int $curtime = 0
    // and some variables that will get read each step
    float $throttle = 0.0
    int $time = 0
    float $rpm = 0
    
    while 1
    {
      $time = simtime
      if $curtime < $time
      {
        $curtime = $time + $checktime
        $throttle = get $car throttle
        $rpm = get $car rpm
      }
      // update throttle every step anyway
        if $rpm > $offtarget
        {
          if $throttle < $offthrottle
          {
            set $car throttle $offthrottle
          }
        }
        else if $rpm > $idletarget
        {
          if $throttle < $decthrottle
          {
            set $car throttle $decthrottle
          }
        }
        else
        {
          if $throttle < $incthrottle
          {
            set $car throttle $incthrottle
          }
        }
      interrupt
    }
    Also in car.ini, move idle downward so the built in (very stable) idle won't kick in.

    Basically I worked out numbers to use by opening the ctrl+4 debug and finding the amount of throttle necessary to idle at 1600 rpm, then moved a little away from there (which was 0.20) to have 0.22 and 0.16.
    Above the $offtarget it'll use the $offthrottle amount, so if that target is set higher the car will approach idle more slowly (equivalent to existing idlerpm really)

    Changing the $checktime is how you set the speed it updates, moving inc/decthrottle closer together will set how fast it rises/falls.



    I suppose changing the throttle is more simulating a slow idle sensor (whether that's the idle air valve or the electronics controlling it)
     
    Last edited: Apr 7, 2014
    • Like Like x 2
  8. That's a nice model to get a lumpy effect.

    Iirc there are two idle methods, but in theory this should work over either of them as long as they have the hard-coded value set low enough under the ones set in this script.


    I hope Ruud updates us all with a newer version of Racer soon with the scripting languages fully matured so we can focus on just using one (rather than a mix of qscript and onyx and the newer one he's been implementing which is more powerful again)

    We could really start to make nice modules like this that are cheap and implement really well with the cars and other features like turbos and traction controls that all interfere with the throttle based upon different parameters.


    Cheers

    Dave
     
  9. Stereo

    Stereo
    Premium Member

    Yeah, I stick to qscript since I know how to make it work per-car etc. (it's been a while, but I think the Onyx scripts were running hardcoded to a particular car?)

    Actually though, the ABS script I use was failing for AI so maybe qscript doesn't really work, either. I haven't done a lot of multi-vehicle testing.

    The PSystem nodes are a really nice way of accessing/modifying car info, it just needs that bit more flexibility of not having to say "car0.suspension0.k" but letting you use the script owner's suspension0.k.

    That it works as well as it does puts Racer way ahead of most other games, it just needs the polish, like you say.

    Active differentials via oxs for example can implement whatever electronic TC is done at the diff in modern cars. Although being limited to +torque at the first output, -torque at the second, isn't quite that, on its own.
     
    Last edited: Apr 8, 2014
  10. Yeah Alex and I had some real fun with scripts and multi-player.

    The active rear toe steering on the Porsche 918 was seeming to share variables so if Alex was going around a bend my car would steer the back wheels as if it were a bend too... then he'd be getting my power assisted steering script impacting his FF or something odd!



    There is no doubt that auto-scoped scripts that exist in car folders would make a lot of sense. Only when you specifically desire non-auto scope should that occur. The rest of the time it should all be assumed you are referencing the car where the script is located.

    That is the logical approach and since we've never tried doing anything except that since scripting appeared it seems a good idea for a default behaviour :D



    ABS should work ok with AI, but sometimes it gets confused it seems as I've had AI not wanting to break for corners... but then reset it all and it's working ok. Weird.

    ABS via qscript is possible now without using any onyx references, just my early example used Onyx but it's best to just use the brake bias adjustment via qscript iirc...

    Dave
     
  11. Stereo

    Stereo
    Premium Member

    Yeah, I didn't look too closely at what was going on but it seemed like the AI was pushing the pedal to the floor and just failing to slow down. The Racer AI's not really that competitive anyway, the 100% guys were accelerating to a top speed about 30km/h below mine, doing laps ~79 vs. 95 seconds.
     
  12. Yeah the AI can be hard to get working really nicely.

    I've used the training AI and it can get quite good results with an appropriately dense spline mesh (but running on polygons)
    Too dense splines and the AI will over-run on corners too easily, too sparse and then you don't get good optimising braking points hehe.

    But about 10-20m intervals and they seem pretty good.

    In the end I think I tend to add 25% power so I'm always accelerating way beyond the car, so it's really using full power on straight aways.
    I also add a bit more weight to smoothen out the drive, reduce brake performance etc... that way the end AI car can run without it's boosts and hopefully drive pretty well within the AI line I set.


    I remember years ago reading about a Ferrari game on the PS1. 360 Challenge, or something. They used a neutral network type learning system for AI where they provided track outlines and driver inputs and then selectively bred AI that seemed to get good lap times.

    That seemed a good approach I think, rather than the enforced explicit AI we have now which can't really drive but just aims for certain points at certain speeds.

    It works but it's limited in that every single car needs AI to be made for it for every track, and even simple changes to a car physics can mean the AI no longer works perfectly in all areas of a circuit. Ie, ends up not using all the speed down the straight, but is maybe more unstable in a quick left/right element etc.


    Hmmm

    Dave