Let’s brainstorm and discuss all of the possible ways to spawn objects.
Brute force: Some people like the brute force approach where you pick a random X, Y and then delete or move the object until a valid location is found. This approach isn’t my favorite especially when there are a large number of possible invalid locations. Although, separate objects can help in some situations.
Choose a random side and a random position.
Choose a number from 1 to 4
If 1 pick a location between 0,0 and camera bounding box left, top
If 2 pick a location to the right meaning
Camera bounding box right, top to dungeon width, camera bounding box bottom
Etc.
The downside is it’s not weighed. A larger side would have the same odds of getting choosen plus counting spawned objects would be vague because there would only be 4 areas. I asked a bot for weighting, IDK if it would work but it still doesn’t help with the count.
Spawn points or spawn zones
Both approaches would be similar. Add either objects to be used a spawn point or an object used to create a spawn zone.
You would then pick a random object that isn’t on the screen or for zones the player isn’t in collision with. Edit: although, the collision check approach wouldn’t work when the player was close to another zone. So, IDK how to choose this. Maybe a mixture of both approaches. This is similar to a room based method.
For points you could either spawn from the point which would require more points to spread them out or spawn with a random distance from the point like X() + random in range (-200,200) for X and Y.
For a zone object, you could spawn within the bounding box of the object.
To count the number of spawned you can use the spawn behavior settings although adding objects manually is much more efficient and customizable.
To count the objects near a point, you can use a distance condition and the number of picked objects condition.
For zones, you can use in collision with the zone with the picked object count condition or expression.
Zones and points sound like they might use resources but the image could be 1 pixel, they’d be stationary, hidden and wouldn’t need a behavior. You also would only try to spawn an enemy every second or 2.
I’m sure there are tons of other ways and variations. But this should create a starting point.