I am currently working on a project where I need a traffic system. I have already setup a system to calculate the path (out of the A* pathfinding project and a couple of waypoints) and a spawn script. Both work fine. Until now I had the Ai cars driving around with a character controller but now I have purchased UnityCar pro and I wanted to change them to over to that, which shouldn’t be that much of a problem.
So now I am getting to the more difficult parts. I want the cars to adapt to the speed of the car in front of them and I need them to reduce the speed before turning.
For the first problem I thought that a Raycast would be the best, and when the distance is smaller then the minimum Distance, I’ll make the car brake. But my problem is that this would only work when the other car is right in front of the car raycasting. That wouldn’t work in a curve/bend. So it would be cool if anybody would have an idea how to fix that.
For the second problem, I don’t really now how to fix that. I mean when the car is turning I can break but that would be too late. So I need the car to break earlier. But I can’t make it break every time it comes to an corner. So it would be cool if anyone would have some infos about that.
And I have one last problem. I need to check whether the car is too close form the curb. Again here I have no idea how to check that.
I already thought about buying a traffic system, but I only found one system and it costs about 3000$ a license and that is definitely way too much for me
The idea sounds good. But how would I bend the plane based on the cars path travelled?
Well I mean when a car gets to a corner it would usually slow down before the corner. Then it would turn and accelerate again. You wouldn’t try to take a corner with 80 km/h in a city. So I need to detect when the car is going to turn, before it turns so that I can make it slow down.