How to prevent actors from spawning in inaccessible areas?

Simplest thing you can do is to make a linetrace or boxtrace from the players camera forward. Then based what it hits and where for example:

  • if it hits ground and it has space spawn
  • if its too close or it doesn’t have space pick different spot you hit and keep checking
  • if there is no space just print a message that there is no spot to drop an item

Also if you have nav mesh generated everywhere you can query it for closest walkable location near player.

And when spawning an item there are actor spawn parameters that can adjust you the location of spawn if it would be colliding with something.

For vital items i would consider blocking ability to drop it entirely but depending on your game design and structure you might want to handle it in some way.

Hopefully this answers your question

2 Likes