Core Concepts
The Runtime Spawner Package (com.pixelwizards.runtimespawner)
The Runtime Spawner system is built from a small number of modular components that work together to control what, when, and where things appear in your game. You can mix and match these systems to create dynamic encounters, adaptive pacing, or persistent world population.
This section explains the core building blocks and how they fit together.
1. Runtime Spawner
The Runtime Spawner is the heart of the system — it manages all active spawns and enforces global rules.
It is responsible for:
Tracking active instances and enforcing alive caps.
Managing spawn queues, cooldowns, and deferred retries.
Executing spawns via Locators (where to spawn) and Executors (how to instantiate).
Respecting NavMesh placement policies and Spawn Hint priorities.
Coordinating with factories and object pools for efficient reuse.
Think of it as the engine that executes spawns — everything else provides context and control.
2. Spawn Entries
Spawn Entries define what the spawner can create.
Each entry specifies:
A Prefab reference (enemy, NPC, pickup, etc.)
Weighting or probability
Optional Spawn Tag (used by rules, filters, or waves)
NavMesh Placement Policy – Require / Prefer / Ignore
Optional deferred retries for “Require” placements
Spawn Entries are grouped into Waves, referenced by Rules, or managed globally by region spawners.
3. Waves & Looping
A Wave is a structured set of Spawn Entries with its own timing and repetition logic.
Waves define:
Spawn count (min / max)
Delay between individual spawns
Interval between wave loops
Looping mode:
Duration – repeat for X seconds
Max Loops – repeat a fixed number of times
Until Signal – run until stopped by code or event
This lets you build encounters that sustain pressure, rather than fire once and end.
4. Spawn Director
The Spawn Director controls difficulty and pacing over time. It references an Intensity Profile that defines how the world scales across “steps” (e.g., early → mid → late game).
At runtime, the Director:
Selects the current step based on time or progression.
Applies step settings (alive caps, spawn rate multipliers).
Notifies connected systems (like Special Encounters) to align their gating.
This provides escalating tension or recovery phases without custom scripting.
5. Intensity Profiles
An Intensity Profile is a ScriptableObject that defines the pacing ladder for your game.
Each Step configures:
Global alive cap
Spawn and wave rate multipliers
Optional weight scaling
Step duration or trigger logic
Profiles let you define difficulty curves once, then reuse them across multiple levels or spawners.
6. Special Encounters
Special Encounters are rule-driven conditional spawns that occur alongside normal waves. They are managed by the Special Encounter Manager, which references a Special Profile.
Each Special Rule can include:
Target prefab or entry
Caps & cooldowns
Step range gating (active only within certain intensity steps)
Telemetry thresholds (pressure, average player HP)
Distance & line-of-sight filters
Spawn Tags to direct placement
Optional LOS-based placement or NavMesh requirement
Use this for bosses, elites, flankers, or reactive events that respond to player behavior and pacing.
7. Telemetry Providers
Telemetry gives the system awareness of game state — such as how intense combat feels or how healthy the team is.
The Special Encounter Manager can query an ISpecialsTelemetry provider for:
Pressure(difficulty or tension level)Average Player HP(team health average)
You can:
Use the included BasicSpecialsTelemetry asset for testing, or
Implement your own provider that reads live game data (e.g., from a Difficulty or PlayerManager service).
Rules that require telemetry will simply skip spawning if no provider is available — safe by default.
8. Spawn Hints
Spawn Hints are optional scene markers (EnemySpawnHintPoint) that help the spawner choose where to place entities.
Each hint includes per-point rules:
Minimum / maximum player distance
Line-of-sight rejection (deny if visible)
NavMesh projection settings and area masks
Tags for rule matching
Soft reservation cooldowns to prevent clustering
Hints can operate in Hint-Only mode (strict authored placement) or as weighted suggestions blended with procedural sampling.
9. NavMesh Placement Policy
Each Spawn Entry defines how strictly it obeys the NavMesh:
Require – spawn only if a valid NavMesh projection exists. Deferred retries if unavailable.
Prefer – spawn immediately, activate agent when NavMesh is ready.
Ignore – skip NavMesh checks entirely (for flying units, effects, etc.).
This gives fine-grained control over where and how entities appear, especially in dynamic or baked-on-demand environments.
10. Deterministic Seeding
The system supports deterministic random generation, ensuring consistent results across runs.
Using:
RuntimeSpawner.SetGlobalSeed(int seed);The same seed + scene setup always produces the same spawn pattern — useful for debugging, procedural generation, or network sync.
11. Factory & Object Pooling
To avoid costly instantiation and destruction, Runtime Spawner uses object factories built on the Megacrush Object Pool.
You can select or create factory assets for your environment:
SinglePlayerPoolFactoryAsset – local pooling (default)
FusionFactoryAsset – for Photon Fusion integration
PUNFactoryAsset – for Photon PUN 2+ integration
Factories implement the IObjectFactory interface, allowing you to plug in your own pooling or ECS system if desired.
12. Networking Integrations
The package includes optional samples and adapters for:
Photon Fusion 2.x
Photon PUN 2+
These provide drop-in factories and bootstraps to replicate spawns across the network using pooling-aware flows. The host / master client runs the spawner, while other peers receive replicated object states.
13. Extensibility
The system is designed to be modular and replaceable:
Spawn Locator – controls how positions are selected (sampling, hints, etc.).
Spawn Executor – controls how objects are instantiated (pooling, networking).
Telemetry Provider – reports game intensity and health data.
Object Factory – integrates with your preferred pooling or network backend.
Every major component can be swapped, subclassed, or scripted to suit your project’s architecture.
Putting It All Together
The Runtime Spawner executes and tracks all spawns.
Waves define how and when they appear.
A Spawn Director and Intensity Profile control global pacing.
A Special Encounter Manager introduces boss-like or situational spawns.
Optional systems — Spawn Hints, Telemetry, Pooling, and Networking — extend this foundation for scalable, performant gameplay.
The Object Pool Package (com.pixelwizards.objectpool)
The Object Pool package has no editor-facing functionality itself, but implements a clean interface for creating and managing reusable pools of objects for your games.
You can find the API documentation for the Object Pool package online here:
Last updated