Mapgen code and player and enemy scripts never check for objects outside of the instantiated map bounds, so regenerating a map will sometimes place the map walls under the player and/or enemy objects, allowing the enemy to z-clip, and the player to get pushed outside of the bounds of the map.