The Daily Click ::. Forums ::. Klik Coding Help ::. Top down car AI
 

Post Reply  Post Oekaki 
 

Posted By Message

vetmora120



Registered
  07/01/2010
Points
  273
22nd March, 2012 at 22/03/2012 04:48:30 -

Hi Guys,

If I were to create a top down car AI, what would be the most effective way to do this?

To elaborate a bit something to think about would be the GTA cars that drive around the city. At the moment I'm thinking objects at the intersections that randomly choose the cars direction; can be either left, right or straight on, obviously depending on the road. This would be easy enough however I would the cars to turn smoothly using 360 degree rotation.

Overall I have ideas of how each thing could be done, but not exactly sure how to mend it all together.

Does anyone have any thoughts?

EDIT: Almost forgot, the roads would be all horizontal and vertical, so it makes it easier and simpler (no crazy windy roads or anything like that)

Edited by vetmora120

 
n/a

Sketchy

Cornwall UK

Registered
  06/11/2004
Points
  1971

VIP MemberWeekly Picture Me This Round 43 Winner!Weekly Picture Me This Round 47 WinnerPicture Me This Round 49 Winner!
23rd March, 2012 at 23/03/2012 23:48:03 -

The basic concept is very simple. You just make it grid-based and have each square the width of a single lane of traffic. You have an array containing the possible movement directions in each square, and when the car enters a new square, it picks one at random.
Traffic lights just synchronize a group of array values.
That's exactly how GTA does it, as you'll see if you ever play around with the GTA map editor.

Added to that though, cars need to react to moving obstacles including other cars (and know who has right of way), find their way back on to the road if they're in an accident, accelerate, brake, overtake...
So while it doesn't seem that hard, there's actually an awful lot you need to think about.
And then if you want police cars/fire engines/ambulances/etc it gets worse still.

Anyway, a *very* basic and buggy example: https://skydrive.live.com/redir.aspx?cid=b1e7ee094271bbda&resid=B1E7EE094271BBDA!507&parid=B1E7EE094271BBDA!131&authkey=!
One day, I might make a proper traffic system, seeing as I already did the 3D engine to go with it - but it won't be anytime soon.

Edited by Sketchy

 
n/a

vetmora120



Registered
  07/01/2010
Points
  273
26th March, 2012 at 26/03/2012 01:22:35 -

Hi Sketchy,

Thanks for replying. I didn't know that was how GTA did it even thought I have played around with the map editor when I used to play it a fair bit. It's quite a simple and clever concept.

Your example is quite cool, but buggy as you said. Thanks for the info, I'll develop it further and see what I end up with.

 
n/a
   

Post Reply



 



Advertisement

Worth A Click