mchrbn / unity-traffic-simulation

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

Doesnt follow waypoints #2

Closed menez1111 closed 4 years ago

menez1111 commented 5 years ago

Hello, I am trying to understand your system for long time. I am new on unity and codding and github :) I made a city for my taxi game and i used your system . But when cars get collision or they leave the waypoints they dont come back the red line. So I made a system only by Segments it worked but that time every car want to go Segment 0 first. I hope you understand the situation my english not very good .

Thanks for the system

mchrbn commented 5 years ago

Hey! I will try to make a video tutorial this week/week-end that shows how to create a system from scratch. In the meantime, you could also share your project with me and I can have a look on what's the issue because I'm not sure I have understood well where the problem comes from.

menez1111 commented 5 years ago

Hello its my project file.

1-I did a system with a lot of segments because cars never miss segments if they miss they go back and touch the segments. If there is no a lot of segments they go nex segment very wide angle.

2- Also, in my game cars sometimes come very close and they go 3 -4 car together which is bad.

I tried to add Intersections on turns of the map to fix close cars but I couldnt use ıntersection probably because there isnt other sections because I just made 1 way.

3- I couldnt change speed of cars . I change minimum and maximum speed but it doesnt work.

THANKS for helping me sorry for taking your time.

Taksi_Trafikli_19_AGU.rar https://drive.google.com/file/d/1Yz4MunOaRZG9vhqqIA7reupqFqOBVGxq/view?usp=drive_web

Matthieu Cherubini notifications@github.com, 19 Ağu 2019 Pzt, 05:57 tarihinde şunu yazdı:

Hey! I will try to make a video tutorial this week/week-end that shows how to create a system from scratch. In the meantime, you could also share your project with me and I can have a look on what's the issue because I'm not sure I have understood well where the problem comes from.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/mchrbn/unity-traffic-simulation/issues/2?email_source=notifications&email_token=AMZN7GTLFCZ5JMA4CYW3BKDQFIDZNA5CNFSM4IMPJQ5KYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD4RRO5Y#issuecomment-522393463, or mute the thread https://github.com/notifications/unsubscribe-auth/AMZN7GUSYXQT2FO5JWP3PP3QFIDZNANCNFSM4IMPJQ5A .

mchrbn commented 5 years ago

Hi,

I saw that you are using an older version of the traffic system, update it as few things should be improved!

I quickly checked your project:

1: I tested on your project to build one traffic system with only one big segment with a lot of waypoints and it works - you shouldn't need to build a system with a lot of segments like you did. Basically segments are only for linking different paths in intersections. For example, if you have one big road that loops (like in your example) then you should only have one segment with a lot of waypoints...If you have one road and then the car can either go to a left road or a right road (intersection) then you need 3 segments (one for the initial road, one for the left road and one for the right road).

Also if you have a very long straight road (like in your example) then you don't need to add so many waypoints, you can just add one at the start of the straight line and one in the end of the straight line...and maybe one or two waypoints in between in case but not that much.

It is odd that the car are missing segments it never happened to me: make sure that the car is on the segment line (or not too far). Also make sure that if you rotate your car, when you place it into the world for its starting position, that you rotate the whole object and not only the mesh otherwise the raycast will point in the wrong direction. If it still happens, send me an example with this issue.

2: Let me know if that still happens once you update your code with the new version. Also you might want to increase the Raycast Length in the CarAI so it match the size of your world (as your world is bigger than mine). This is an issue I saw few time and not sure it is still fully fixed. Let me know.

3: Yes there is a small bug there, to fix it change the 'Full Torque Over All Wheels' to 100000 in the Vehicle Physics script.

menez1111 commented 5 years ago

Hello

I tried to update with new version but I got a lot of error .I am using Unity 2018.3.14f1 . May you are using 2019 version in the new update. I think I solved problems about version problem but it was very confising I cant remember how I did . Also, I couldnt solve old problems. So maybe I did it in wrong way how should update my project with your new system. Coppy paste didnt help.

I couldnt solve old problems .I make a sytstem with a lot of segments because when I change the AI car positions they go last segment with most narrow angle and its very good. I tried making system with one big segment AI cars sometimes go arround like crazy and if it didnt happen when I change their position they cant back to redline they are trying to go nex segment in very wide angle. Sorry for English but how I can explain my problem I dont know. I know its too much but if you take a video or something like that in my project it would great. (note : new gizmos on screen makes lag maybe because i have a lot of segments so i closed that . It was good tool anyway) THANK YOU

menez1111 commented 5 years ago

My problem on paint :)

image, image, image

mchrbn commented 5 years ago

I tried with the 2018 version and didn't get any errors - maybe the errors you get are from another package?

From the image you sent me, the issue is that you put the car on the other lane but do not rotate it (car A is going the opposite way as the way you positioned car B)! At the game start, the car are looking for the nearest waypoint that are in front of them. Either put the car on the right lane or rotate it 180 degrees.

63389304-f811f700-c3b3-11e9-9b5f-4d643087313e

menez1111 commented 5 years ago

I tried with the 2018 version and didn't get any errors - maybe the errors you get are from another package?

From the image you sent me, the issue is that you put the car on the other lane but do not rotate it (car A is going the opposite way as the way you positioned car B)! At the game start, the car are looking for the nearest waypoint that are in front of them. Either put the car on the right lane or rotate it 180 degrees.

63389304-f811f700-c3b3-11e9-9b5f-4d643087313e

I didnt change the position before game start . I change the car's position on gameplay and car try to go nex segment . If my player hit to car they do same thing . I am very sorry for couldnt explain my problem. When AI cars change position they tryting to go nex segment they with right angle . If way is long its very big problem so I made a lot of segments to solve this problem.

menez1111 commented 5 years ago

They dont go back to their waypoints they back to their segments and if distance of 2 segments is long they are going on out of redlines (waypoints)

mchrbn commented 5 years ago

They dont go back to their waypoints they back to their segments and if distance of 2 segments is long they are going on out of redlines (waypoints)

You can add multiple waypoint within one segment. Ctrl+left click create a new segment and Shift+left click create a waypoint within the selected segment.