mchrbn / unity-traffic-simulation

A Unity asset that lets you easily simulate very simple traffic into your scene.
264 stars 57 forks source link

Some cars don't follow waypoints #22

Closed highwaywarrior0 closed 3 years ago

highwaywarrior0 commented 3 years ago

Why would that happen, how can i fix it?

https://user-images.githubusercontent.com/68394892/141800096-c54ea23b-6316-4ef7-8e85-3d3b762b0d8b.mp4

highwaywarrior0 commented 3 years ago

Apparently they are trying to go to Segment-0, but why?

https://streamable.com/teiuwz

mchrbn commented 3 years ago

It could be because of the starting position of your cars - at the start, the system tries to get the closest front waypoint from the car in order to automatically define where the car has to go. But if the waypoint is very far away, it could pick the wrong one.

I can see from your video that you have very long straight segments without any waypoints in between, maybe that could be the issue?

It seems that some cars are driving properly, could you check if these ones are positioned close to a waypoint at the start? And if the one who are driving wrong seem very far away from a waypoint?

highwaywarrior0 commented 3 years ago

Yeah it's completely related to the starting position i think.

If you look at the areas where the problem occurs most, they are bends, where most of the waypoints are located.

And, opposite to what you said, these happen when the cars are too close to waypoints, not because they are too far away. When I move the broken cars away from any waypoint they start driving normally.

Also I tested if it's related to closest waypoint being in front/back of the car too, and no it isn't.

https://streamable.com/tbgapm

mchrbn commented 3 years ago

Mhh did you try to change the value of "Segment Detection Threshold" on the "Traffic System" gameobject? If not, try to increase the threshold a bit.

If this still doesn't work, you can upload your project somewhere so I can have a look.

highwaywarrior0 commented 3 years ago

I increased it from "0.1" to "2" and now everything seems to be working properly, thanks