Update (21.04.15 | 13:50):
Added Showcase video to the Screenshot section.
Today i worked on the CarAI itself. I added a state system and started with the avoidence. It now stops
as soon as i finds another car that is in front and active (not active means it is parking and the AI better drives around it).
It still needs a lot of work but i’m happy with it for now.
PS: The first car that arrives and drives into the stairway is already fixed. I forgot to clear the shortest path array, so it wanted to drive to
the next node which was the first node of one of the other cars. (Video)
Small Update (19.04.15 | 17:58):
Ok, i found out that i can make custom events callable in the editor. So now you can easily add and delete new nodes
by just click on an existing node and clicking the specific button. AWESOME isn’t it?
Hey party people,
so yesterday i started working on a little fun project. My other current project is getting way to big for me and i need a break from it.
That’s why i started creating a traffic system! The first goal is, to design it similar to GTA, where cars follow the best route to there destination
and avoid other cars, react to traffic light etc.
I started by creating a node system and implementing the Dijkstra Algorithm to find the shortest path.
For now there are only picture, because i am not happy with the video i recorded. Will need to rerecord this.
I will place the screenshots at the end of the post.
Features right now:
You are able to create nodes and connect them (by hand for now). Then you can select an AI Car and give him one node as his target node.
Then he will ask the system to calculate the shortest path for him and starts driving.
The car is very slow for now, because i didn’t want it to break out of a curve.
The nodes themself are actors and they will contain a lot of information.
Features planned:
Regarding the traffic system:
I want to have an easier way to place the nodes. At the moment it is a pain to create a new array entry for one of the possible next waypoints
and search for the name (with almost 90+ nodes). I want to be able to directly say “create me a new node connect to the selected one”.
Maybe i can use Blutility for this, but right now it seems broken, because the buttons for the functions don’t show up.
The nodes will contain information like “Parking Lot”, “Traffic Light”, “Suggested Speed to drive”, etc. So that a node can be modified to be
a traffic light and manage a crossway with other connected nodes. Or as a parking lot to be a destination where a person leaves its car.
This means i will need to implement a few road signs, so that the traffic won’t collapse.
Regarding the cars
Right now they only follow the path with a specific speed and depending on some numbers, steering and slowing down/getting more speed.
I just pushed in some numbers so that i can test the system. I want to have the car calculate its own speed for a specific distance to a new node
and also hitting the brake if it would be too fast to take the turn. Also, if a given node has custom values, override the car ones with these.
Because maybe you have 2 nodes in a small distance, but you don’t want to loose any speed.
In the future, the cars should stop if something is infront of them, honk if it is a person and try to drive around it, if it is an obstacle that isn’t active.
Like a broken car. Also stop behind other cars, so that they don’t crash into each other.
What can i use this system for?:
Yeah that’s a good question. If you are creating a city simulation, it would be a good thing to have this. Also if you want to make GTA5 (please not only because i just said so), you can use this.
But it can also be used for RTS games. If you have a system where buildings are connected through roads and the delivery car is only allowed to move on these, then it
would be good to have this, so that a car can calculate the shortest path to a building. You could then disable the cars collision check, so that they can move through each other.
Future plans:
I don’t really have future plans for this. It is a fun project of course, because i don’t need this system for my own project. It just happened to be interesting
to implement it in UE4 while playing GTA5 the last few days.
If a lot of you say “OH MY GOD I NEED THIS”, then i will think about putting this on the market for 10-20€ (depens on how much time it would take me to finish).
Screenshots:
http://puu.sh/hjiIQ/adb1b9f036.jpg
http://puu.sh/hjiJH/450d3c7da8.jpg
Green spheres indicating the path that the system gave the car:
http://puu.sh/hjjzh/2d38e6ce29.jpg
Showcase Videos