How to I make a car idle roughly?

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!
 
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).
 
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
 
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:
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
 
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:
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
 
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.
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.
 
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
 
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 }
where do you go in the files to put this code?
 
Not trying to sound dumb but what steps do you take to find those folders, because not one of my cars folders has a scripts\physics folder.
unless its all folders you have to add into the cars physical folder.

all my modded cars have the typical files.....
animations
data
extension
sfx
skins
Texture
ui
ect ect depening on the car
 
That doesn't sound like Racer, most cars have a single folder containing the ar, wav files, physics data, etc. and you create the script folder there.
 

Latest News

How long have you been simracing

  • < 1 year

    Votes: 209 14.1%
  • < 2 years

    Votes: 153 10.3%
  • < 3 years

    Votes: 149 10.1%
  • < 4 years

    Votes: 113 7.6%
  • < 5 years

    Votes: 213 14.4%
  • < 10 years

    Votes: 177 12.0%
  • < 15 years

    Votes: 117 7.9%
  • < 20 years

    Votes: 80 5.4%
  • < 25 years

    Votes: 64 4.3%
  • Ok, I am a dinosaur

    Votes: 205 13.9%
Back
Top