Pathfinding dest. respecting street hand - traffic rules

Get help using Construct 2

Post » Wed Mar 21, 2018 1:31 am

Hi folks; how are you? I got i huge dobt that is consuming for at least one year.
First; i made a (T ) street surrounded by walls; which is solid. Each hand of the street has its angles place accordly to its direction. For example; the left hand; has its angle set to south; and the right hand has its angle to south; so it would make possible to the car follow a path without invading the wrong way. I placed a car on right side of this T street. It must go to a second vehicle that is on botton of the T street. It does it very well; but the car ignores the right hand and just invafe the wrong way to reach its objective. How can i do to fix it? Thanks! Then ill post some prints of what im saying if you like.
B
7
S
3
G
3
Posts: 19
Reputation: 2,109

Post » Wed Mar 21, 2018 3:39 am

Here is one way:

Make an invisible tilemap (green area) as on this picture:

Image

Tilemap should not be solid.
For Car in pathfinding properties set Obstacles:Custom and in evens add that green tilemap as an obstacle.


But if you have lots of cars moving in different directions, this trick will not work.
You might need to use some other method instead of pathfinding.
Image

Did I help to fix a problem in your game? You can buy me a cup of coffee :) If you'd like to hire me, please see this post
B
17
S
9
G
157
Posts: 2,212
Reputation: 83,505

Post » Wed Mar 21, 2018 4:24 am

dop2000 wrote:Here is one way:

Make an invisible tilemap (green area) as on this picture:

Image

Tilemap should not be solid.
For Car in pathfinding properties set Obstacles:Custom and in evens add that green tilemap as an obstacle.


But if you have lots of cars moving in different directions, this trick will not work.
You might need to use some other method instead of pathfinding.





Hi man and thanks for the help. It's a great idea! But as you said, that's the true, i want to create a AI traffic system just like GTA1 Top down. I never fund a post that talks exactly about that. I found some .capx, but they didn't helped much. i thought for once i could build up a traffic system using pathfinding, but as i tried in many ways before, it won't be possible for various cars, right? Thanks anyway.
B
7
S
3
G
3
Posts: 19
Reputation: 2,109

Post » Wed Mar 21, 2018 6:29 am

Well, you can probably define 4 tilemaps like that on each intersection (for cars coming from each of 4 directions).
When a car approaches the intersection, check which of the tilemaps it is not overlapping and use this tilemap for pathfinding for this car.
Image

Did I help to fix a problem in your game? You can buy me a cup of coffee :) If you'd like to hire me, please see this post
B
17
S
9
G
157
Posts: 2,212
Reputation: 83,505

Post » Wed Mar 21, 2018 7:08 am

Check this demo:
https://www.dropbox.com/s/onbdpqo7pfpvf ... .capx?dl=0

Left-click a car, then right-click the spot where it should drive.
Image

Did I help to fix a problem in your game? You can buy me a cup of coffee :) If you'd like to hire me, please see this post
B
17
S
9
G
157
Posts: 2,212
Reputation: 83,505


Return to How do I....?

Who is online

Users browsing this forum: blackhornet, Zed2100 and 4 guests