AI Traffic System

how could i make the cars have locations to go to? like from a house to a store

1 Like

Maybe you could incorporate a “goal” system.

So if a car’s goal is the gas station a few blocks away, it would map the path for the car to go to get there.

1 Like

To elaborate on what trtman33 mentioned, an A* Pathfinder is a popular choice for that. You could use tyridge’s NodeGraph plugin or sleitnick’s Node Map.

Using one of these plugins, you can draw a nodegraph on your map. This is the road your car can drive on. For example, this is what an intersection could look like:

When your car is at the house, you can use the pathfinder module from your plugin to get a list of nodes between the house — store.

Drive to the first node in the list. Whenever your car is less than, let’s say, 20 studs away, you drive to the next node in the list. And that basically repeats till you reach your destination.

When you got that done, you can play around with the 20 studs range. Smaller ranges result into a more rigid path following, while wider allows more shortcuts. You can even make this dynamic, for example based on velocity! (Faster the vehicle is, the less shortcuts it’s allowed to take)

path_different_radius

Hope that helps!

2 Likes