How can I make NPC's seek cover?

I want to make an AI that seeks cover.
A problem is probably gonna be that some platforms are gonna move.
I haven’t really seen anything about it on Roblox and I also have no idea beside just making lots of raycast/objectcasts, but that would lag eventually since I try to make a horde type shooter and most enemies have guns and other projectiles to attack.

1 Like

An alternative would be pre-designing “areas of cover” which the NPC’s could flee to.
These can be BasePart’s.

This introduces a new complication: is it actually cover?

You can check if it’s in the sight of enemies separately. Then add the areas of cover which are out of sight to a table that can be used by the AI to immediately know which areas are safe.

Let me know how this works.
Thank you

Well, like I already said, that would be an issue probably since I got some moving platforms and I don’t really like that way too. Additionally, it would create an issue of it ignoring placable barriers/walls, or I add it into the table. But like I said, it really doesn’t sound like a good fix, it also would be annoying since there are lots of places that could be considered cover and if I forget to add a position, I’ll have to add it. Now this could be a valid fix, yes, but the maps are relatively big too.

Let me know if anything I said was wrong