AI In Racing Games

Blitz3D Forums/Blitz3D Beginners Area/AI In Racing Games

Q(Posted 2006) [#1]
How do you guys handle AI in a racing game in 3D? Like, keeping the computer controlled players on the track.


WolRon(Posted 2006) [#2]
However you want.

Waypoints probably work fine.
Each waypoint could contain specific data about the track at that point, such as:
- next track waypoint,
- waypoint skill level (easy, medium, hard; "racing line"),
- track width (lanes?),
- track angle (whether or not this waypoint describes a straight-away or a turn),
- track start/finish line,
- suggested speed for this section of track,
- etc. etc.


IPete2(Posted 2006) [#3]
Another alternative is for you to drive around the track and record several different routes, then store them in banks and using an index pointer read the x,y,z, pitch, yaw, roll for each position along the track, switching tracks as need be based on immedaite conditions.

IPete2.


Stevie G(Posted 2006) [#4]
I use a similar method to WolRon. Basically, when creating the track I store a number of waypoints which represent the center of the road.

From this data I can then create a racing line by iterating through the waypoints, storing the distance and angle between the current and next waypoints. From this information you can determine how long a straight is, how long and steep a bend is etc..

For each of the bends I then calculate what the maximum speed that this bend could be taken at depending on your turn rate and maximum speed.

From this you can then determine what the maximum speed should be on approach to the bend, depending on the length of the straight before it so you're cars would gradually slow down before it. You can also determine where the race line should be on the straight .. e.g. gradually moving to the outside left when the next bend is to the right.

Hope that made sense?

Stevie