I’m currently trying to build a system to spawn actors. The spawning system will have a list of spawn points (I’m using Target Points) where the spawn can happen. I want to be able to choose a point that the player cannot currently see.
I’m having a very difficult time figuring out how to do this and my Google searches are failing to even turn up people looking for the same thing. My first thought is to do some combination of a frustum check and a raycast, although that seems pretty slow and I haven’t been able to find info on doing a frustum check anyways.
Is there something built into the engine? Perhaps a cached Z buffer or list of non-culled actors?
Just hold a list of all your Spawn Points, when you go to spawn a new player, do a simple line trace from all Alive players to each spawn point that is within the current Direction and FOV of that player. A simple weighting system can help you determine the best spawn point, especially if your traces return that all spawn points are in view of at least one player each. (Do something like add the distance to a “Spawn Weight” variable on the spawn point, once you have calculated all that, go through your array of Spawn Points again and check which one has the best Spawn Weight value for your needs).
I did a similar basic weighting system like this for my Marketplace package BP Spawning Volumes.
However i didnt use the FOV or Direction of the players to determine the best spawn point, i just did a Line Trace to each Spawn point and weighted them based on distance, so as to keep the Players spawning relatively close together.