Specified mob spawning system

Hi i’m doing some sort of a hack n slash RPG and i wanna have mobs added to it but im a little worried about what way might be the best for the game…

I’ve been thinking of 2 ways of doing it where the first is to make a collider defining areas where mobs may spawn and walk around in, but i feel there is a little disadvantage by doing this since you could end up in having your scene floating with mobs spawn areas… the pros will be really good maintaining and you’ll have a good control over the situation.

The second thing I’ve had in mind is to define it in a mob database (a simple C# Script) and have a spawn place, and a radius of max area to move around. the problem here is it might be hard to control how many monsters islive in order to have a spawn limit also patrolling unit may be buggy (behavior could be defined as a enum), a pros here is that everything could be maintained from scripts only…

So my main question is what would be smartest, or is there a smarter way than those 2 i’ve been thinking of, to inplement into the game? suggestions and simple/idea script are very welcome as well.

Hi there,

think about how MMORPGs out there do it.

There is an area where a mob might spawn (like around the farm house, or on a forest opening). And the mob spawns at a specific rate if the population drops (killed mobs), but never over the population caps. It wanders around, but does not leave it’s area - only if it follows a fleeing player.

If you have a RPG where an area is clean of mobs after a player hacked along, maybe drop the spawn rate down very low. It’s no MMO where you need endless spawns.

Now try to get the abstraction level high from a programming and level-design point of view. Get a Prefab with an EmptyObject + a Spawn Area Script handling the spawn, instantiating the mobs,( that are aware of the area).

Geometricaly, the area could be defined by a group of emptys, added to a list on the SpawnArea Script and defining a Polygon in the order of their list insertions.

The script randomizes a point in that area (and has a Reference to the Ground geometry to calculate the height) where the mob will be spawned, given a reference to the area geometics and activated. The mob is choosen from a List of mobs&spawnrates&population-caps, also known to the SpawnArea Script.

The Mob then lives his own live, aware of the area. While the area is aware of the living spawned mob counts.

Well that would be my first thought.

Best of Luck!