Race AI System

Hello everyone, :smile:

I’m working on a racing game (like Gran Turismo, Forza, etc.) right now i’m working on the AI system, the features include by now are as follows:

  • AI steering
  • Breaking
  • Overtake
  • Braking if opponent in front
  • Collision prevension - if opponents on sides
  • AI drivers can determine the maximum speed for cornering
  • Different AI behaivour
  • Pitting
  • Countersteering if the car drifts
  • Also, the system has tire wearing and heating (for maximum grip)
  • Grid position - you set the positions and the system randomly positions all the competitors on the track
  • Pits assignment - the system assigns all the competitors pits positions
  • When the race is finished, the AI system takes control of the player car

Bellow is a video, you know what they say, one picture tells more than a hundreds of words!

Comments are welcome! :wink:

Link to new Thread on Assets and Asset Store

Ok, here is the link to asset store

iRDS - Intelligent Race Driver System

iRDS Manual Download Link:

iRDS Manual Download Link

And here is the Web Demo

Here are the user controls:

Car selection:
Use the left and right arrows keys to select your car

Arrows key:
Up - Accel
Down - Brake
Right and left - Steering

Space bar - HandBrake
A - Shift Up
Z - Shift Down
X - Turn on/off RoadCameras
C - Change Camera Current Car
V - Change camera View (Hood, bumper, cockpit, etc.)
E - Enable/Disable Stability Control
T - Enable/Disable Traction Control
H - Enable/Disable Steer Help
B - Enable/Disable ABS

The video looks good. The AI cars actually drives intelligently. Are you planning on selling the AI system as an asset?

Thanks for your post!

Well actually, I’m planning to do that exactly while continue to work on the game. But currently It’s still WIP, there are some details I’m working on. :smile:

@rhodnius this is looking good and in right direction.

Thanks cupsster!:smile:

Ah no drop shadows under the cars? Not even a simple projector with a shadow texture? Everything looks very promising from here…was wondering what was going on with the brake lights jittering so much with some cars in some turns, etc? They fire rapidly on and off. Other than that the AI move through turns very smoothly.

Hi JamesArndt,

Thanks for your comment. About the shadows, right now I’m more on th AI itself and I would be in the near future getting the Unity Pro, and let it handle the shadows, but you are right!

About the tail lights, i definitly have to work around that, it happens because of the calculations made to determine when to hit the breaks, when the “speed limit” calculated is very similar to the car speed is when it occurs, maybe i should implement a lerp function or smooth… mmmm something else to work on!!:smile:

Thanks again!

Adding projector prefab with blurred car shadow should be max 5 min operation per car even with creation of texture… :slight_smile: it’s not required but faking AO [by projected shadow] always help to “sit” object on ground and adding depth to scene.
About car lights, brake lights usualy kick in after car starts braking so you can store information about this in decreasing variable and adding to this var only vhen you brake. Then evaluate if it is above treshold fo lights to stay on. If not trn them off.
As for front lights flare. cache active cam position and with shortening distance increase flare intensity… If beyond certain distance turn it off completly. :slight_smile:
You can also add exhaust flame and link it to moment of changing gears. But only subtle and for very short time.

my2cents

Thanks cupsster,

I would consider implementing what you and JamesArndt suggest, as it’s seems to be easy to implement.

Thanks again for your comments!

Oh, I forgot to mention, flames are already implemented but not necessary when shifting gears, it occurs when rev’s are really up and you let go the gas pedal. Trying to imitate the high pressure of the engine, that results in small spit of fire.

Also the cars now have blob shadows! :smile:

See picture bellow.

Looks good so far. The animation is good. I also like the different camera views. Lighting ( especially headlights ) are really good also

For an indie game this is really nice work. Keep it up :slight_smile:

@rhodnius Keep up the good work :smile:

Maybe you can make it more pronounced on ground… Projector should support fallof ramp trough which you control intensity of shadow depending on box volume. As an advanced technique you can render out shadow matrix to texture and change offset of material according to closest angle position… Combined with autoaligning of projector it can create nearly authentic shadow like real shadow from Pro :wink:

Thanks cupsster, i’ll try that one out, but I need to upgrade first to current unity release, with the version I have i got a lot more drawcalls from those blob shadows, they are like 10x more!:frowning:

hi rhodinius,

just have a look at the angry bot demo shipping with unity in order to get less draw calls when using blob shadows: they added an extra plane on which the shadow gets projected.
if you just assign a projector, anything that could be effected has to be rendered twice – as far as i know.

lars

That’s good tip! Now I need to open that project again… Do you have any other aces Lars?

Thanks lars, I’ll check it out!, those drawcalls really went up when I included the blobshadows!

Hi lars,

I implemented it, the drawcalls didn’t went up like before, and visually is the same result!, thanks a lot man!

See pictures:

you are welcome!

lars

New updates on the AI System,

  • Improved driving ability of AI
  • More accurate statistics position
  • AI drivers stay more on track, they still may eventually get off track , but is less likely

Also the AI system takes control of the Human controlled car when the race ends.

See videos below:

Improved features

AI Taking control of Human controlled car at end of race