Hello,
I am designing a random pedestrian system to simulate a city. Pedestrians would navigate via a NavMeshBoundsVolume with NavModifierVolumes that would put higher weight on roads (to prevent pedestrians from wandering in the roads). The pedestrians are destined for a random point across the city.
The issue I’m running into is the idea of a crosswalk. I would like the AI to wait until the crosswalk has enabled. Until then they should wait.
I’ve fiddled with using volumes and increasing the weights when the crosswalk is disabled, but the AI just go through the nearby crosswalk, instead of waiting.
I’m not looking for an implementation, but if anyone more experienced with AI could point me in the direction of a solid design, I’d love to dive deep. Until then, I’ll keep tinkering!
Hello,
I am not very experienced but my point of view may help you. I think you should implement a behavior. I mean, the AI does not know that the weights are changing, so if you give them an order to move from A to B, they will the find the cheapest way to reach B. It makes no sense to them for wait.
I think you should give the roads a very high cost (as you do) and a permissive cost to the crosswalks that must be slightly higher than the default costs. Then you should implement a Behavior Tree. This tree should choose the best path which sometimes will include crosswalks. Then the AI should follow the path, but detecting when you are near a crosswalk to wait.
The best way to detect whenever you are near a crosswalk, I think it is modifying the path following component and checking if any segment cross the crosswalk. (see this rama’s post). You could also use an abort observer in the BT when the character is near and facing a crosswalk but this is a bit dirty.
Hope this helps,