Region3 Vs Raycasting for Pathfinding

Hello hello hello!

I’ve recently been working on a pathfinding AI. Simple enough, but the difficulty comes with the fact that it lives on a smooth terrain map. For those unfamiliar, smooth terrain and pathfinding makes for a bit of a nightmare!

I’m trying to be as efficient as possible because a very large number of ai are required on the map at a time. Currently I generate a new grid around each ai of about 16x16 nodes, separated by 4 (the grid that smooth terrain is calculated on). Then, each time a new grid is made, I run through all the nodes, create a region3 around it and determine if there is terrain occupying that node with > 0.5 occupancy (solidish).

Would it be more efficient for me to raycast out from the ai in order to determine which nodes to close off? I can run over 100 Ai at a time with no performance hits using my current method but that’s really not enough. Along with that, I still have many kinks to work out and I imagine it’s only going to get less efficient from here.

Or, if you have a better solution than anything I’ve said here, please feel free to share that too!

Thanks!

2 Likes

Region3 could be used to make sure the AI detect a character going within a specific zone range while Raycasting could be used if the AI can detect from way farther if there’s a character that is not within a blocked vision from the eyes like a wall or somethin