I mean, this would not work well.
- you’d need to send each AI a different coordinate. Here you’re sending only the last one
- you also entirely skipped player world coordinate and are treating the local offsets as world. You’re sending values -30 ↔ 30. Add player world coord at least. And send a unique coord to each AI instead.
This is just pseudoscript
It was just an example of how to calculate some vectors, not something you could possibly plug into an existing system. To make it work with elevation, you’d also need to incorporate some kind of downwards tracing and obtain the location from that. Not to mention narrow passageways that would wreck havoc with this and would need to be be handled as a special case.
Essentially, you’d script a bunch of routines and switch between them:
- follow in line
- surround player
- surround but keep distance
- and so on…
You’d also need to breathe some logic into handling the coordinates themselves - what happens when there’s 17 AIs and only enough space for 12 AIs to chase the player. You may also look into:
if you have not done so already.