Hello everyone, I am making a game, there are 2 bridges in the game. For example, I create 3 AIs. These AIs attack the tower opposite the 1st bridge. They stand on the bridge while attacking. When I create 3 more AIs, they first go to the first bridge, but since the bridge is blocked and their destination is the tower, they try to go, they constantly try to push the first AIs I created and they cannot go. I want to do this. First, let them go to the first bridge, then if the bridge is full, I want them to look for an alternative path and cross the other bridge. How can I do this?
Hi there, this is a good question! I’m going to see what I can find about this, but for now try checking out this page in the documentation which details a bunch of ways for updating the graph during runtime for various reasons.
I’m wondering if tagging your bridges as “Choke Point” and caching which nodes are on the bridge, then setting those nodes to unwalkable when the bridge has a certain number of agents on it would be a good solution. Feels a little hacky?
Yes, that could be a solution, but what I want is a slightly more intelligent entity. For example, even if that bridge is blocked, it will go there and then go to the other side. The game I want to make is basically the same as clash royale.
Ohh I see- if you want them to go to the bridge and then turn around, as if they were not aware that the bridge was blocked until they got there, I’m pretty sure that’s going to take some more custom logic. As far as I’m aware, I do not think there is any solution within Astar on its own that will make an agent go to the bridge, then go to the other bridge when it’s blocked.
Moving collisions attached to the units? They can ignore each other but mask the layer for path checking.
Hi
This is not easy. Are the agents stationary on that bridge? In that case, you could detect when they stop, and then activate a navmesh cut or other graph update that makes the ground beneath them unwalkable. You’ll have to disable the agent’s movement script during this time, because otherwise it will try to move away from this unwalkable region.