There seems to be some debate about whether or not raiders and other creatures attacking my settlements can spawn inside walls I've set up or not. Which is it?
1 Answer
They can.
The way settlement attack spawns work is that they have certain locations that enemies spawn from. In some settlements, these spawn locations are inside the workshop area. Furthermore, some settlements make the fast travel location a spawn point. So if you build the mat for fast travel inside your settlement, then enemies can spawn at that mat.
If you're on PC there are several mods that will allow you to see the spawn locations for each location the game uses. There is also a mod for PC (and possibly XB1) that moves the spawn locations to outside the workshop build locations, making walls truly useful.
All that said, it is still possible to have enemies spawn inside a settlement as a random glitch. This is a problem with the game engine as far as anyone can tell and is unlikely to be fixed by modders, and would require an official fix from Bethesda.
EDIT: As a bit of an update with more complete information, there seems to be a theory that certain spawn locations are scripted to appear at x distance from the Workshop within the settlement. It seems that if this script picks a value for x that is blocked somehow, it will default to spawning at the Workshop within the settlement.