Path movement (circuit) help

BlitzPlus Forums/BlitzPlus Programming/Path movement (circuit) help

MarkInTheDark(Posted 2003) [#1]
I'm after moving objects around a circuit. Similar to a car racing game in the computer controlled objects must be able to 'drive' or move around corners following a realistic path and if required ajusting their path to overtake etc.

Does anyone know of any tutorials etc. that could help?


Rob Farley(Posted 2003) [#2]
Basically you want to give the computer players to have the same controls as the human player.

Then just give them the same kind of information the human has.

So you need to let it know the general flow of the road, therefore set up waypoints all round the road.

With regards to AI, I would suggest having the waypoints far apart for fast bits and close for bits where you need to slow down, this way you check the distance to the next waypoint and this will give you an idea of what speed to accelerate to or brake to.

Also the reletive angle of the waypoint to the angle of the car will give you and idea of how much to steer and in what direction, and if you need to steer a lot maybe apply the brakes.

Now for overtaking... You need to have the car check for cars ahead and to it's sides and adjust it's steering/braking accordingly.

Anyway... I hope that gives you a basic idea.

That said there are hundreds of ways of doing this, this is just one method.


jfk EO-11110(Posted 2003) [#3]
A good illusion of ai is better than real ai that is done badly.
Usually I drive the track and record my positions. Later I use this data for a waypoint system. You can mix it then with interaction.


Richy(Posted 2003) [#4]
There is a section on waypoints using Racing Cars going around a circuit in Kylars Book. Check out the Blitzcoder site for as link


Imphenzia(Posted 2003) [#5]
Hello,

I've been developing a "fake" AI system for my CTCC game and my first approach wasn't good enough so I came up with a new waypoint system.

Here is a picture of my (beta) circuit editor:



As you can see all the waypoints have middle / left / right aim-points. When a car is driving around the track it aims for the closest waypoint in order to cut corners and get a good race line. The faster the car travels the further ahead it looks, this way it can plan to take corners while skidding.

The grid and squares is a data array so the AI cars instantly know which waypoint they are currently at, it's very fast and does not require complex calculations to save time. This way it's also possible to get cars out of sticky situations if they've skidded into a corner as you basically tell them how to get back on the track.

I've also given the waypoints upper / lower values in order to drive under / over bridges etc. Also, if a pitstop is needed it redirects onto another set of waypoints.

I noticed that I don't have to worry about overtaking too much, on this scale the cars quite easily find their way around eachother if one is faster than the other.

Hope this helps, it's proven to work quite good although I am tweaking the system.

Here are the cars in action using this system:


Stefan


cbmeeks(Posted 2003) [#6]
Very nice looking.

The only problem I see with the art is the metal bridge. If you look, the "bumps" on the bridge compared to the cars look huge. It would be like driving over 8 inch high bumps. :-)

Anyway, looks great.

cb


Imphenzia(Posted 2003) [#7]
Very true =) I'll sort that out, heh.


Oldefoxx(Posted 2003) [#8]
If you want a realistic effect, I would suggest looking at
bezier curves. You will find some example programs on the forums which do a nice job of showing them off. A bezier curve you to define a couple of points, and a couple of control points to guide your path as you go from one to the next. The control points can represent a force direction as well as the degree of force being exerted on the object travelling that path. A control point could represent inertia, another can act as acceleration or breaking. The resulting curve can be very realistic, and can be adjusted in mid course if the outcome appears to be leading to some sort of disaster. (If intertia threatens to put your car into the wall, you reduce acceleration or add breaking effort and try to get the curve to adjust accordingly).

Bezier curves are useful another way. Once you project what you want the object to do, you only need to reposition the object in a timely fashion until it is time to figure out what the next curve portion is going to look like. That means far less time spent in lengthly computations, and the likelihood of smoother play.

You can certainly work a rate of acceleration, rate of turn, inertia as it tends to keep you in motion along one path, etc., but the problem with those approaches is that they do not allow you to see ahead as to what will happen two or three or five computations from now. And so you do not have a game plan being inacted, If you calculate that far ahead, and find yourself in trouble, you also find two immediate problems confronting you: (1) At what point can you start making change to fix the problem, and (2) How can you make the shift from one course of action (such as accelerating) to another (such as hard breaking) appear natural?