ProceduralGridMover unit teleporting problem

I know well what happens to you; when it happened to me, I said, ‘Who cares, anyway…’. In a game where you navigate the grid, you can’t have all the AIs active; 10,000 NPCs moving and ‘thinking’ would overwhelm any PC. So, imagine you have the view on your monitor, and let’s say the pathfinding grid is three times as large. In addition to this, you’ll have a Proximity Manager that maintains a list of all your NPCs. If these NPCs are outside the screen, the Manager will deactivate them. When they come back on the screen, they will be reactivated. This way, no NPC will ever be teleported because they won’t move if they are outside the grid, as they are deactivated.

In the first image, you can see a map in the editor not running. As you can see, there are about a hundred NPCs (green-orange symbols). In the second image, it’s running, and there’s the movement of the grid. I deactivate the NPCs outside the grid and reactivate them when they are at a certain distance from the screen.
The teleportation is “done” by IAstarAI (like FollowerEntity), not by the Procedural Graph Mover. If you deactivate the NPC, you deactivate the script that teleported it.

Some advice: Create a Proximity Manager script and a Proximity Managed script. The first is the manager, and the second should be placed in each AI. In the Managed script, include a bool variable to indicate whether the object has been disabled by the Manager or by something else (death?). Pay attention to the script execution order, especially if it works in the editor and then not in the exe (you may need to adjust the execution order).


1 Like