Traffic System

Hey,

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 :smile:

Maybe you want to try using an invisible object attached to the cars front in shape of a bent plane and check if its colliding with a car.

Sorry but i dont get your second issue.

Viel Erfolg! =)

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.

I hope that’s a little bit clearer

Oh i rather thought about a bent plane made in blender or 3DMax than of the default Unity plane.

Also place an invisible cube in the middle of the corner and let the car try to detect them by raycast maybe?

Another idea: Put invisible and phantom walls befor the corner and let the car decrease its speed when colliding with.

well the problem with the corners is that the car always has the option of either going straight or turning

It’s a crossing then and the car has to check for crossing cars anyway, doesnt it?

that’s true. I didn’t think about that. thanks man!