Spawn Hint Settings

Global config to control how the system handles Spawn Hints

Spawn Hint Settings (Scriptable Object)

A project-wide configuration asset that controls how the spawner queries and uses EnemySpawnHintPoint markers.

Create one via Create → Runtime Spawner → Spawn Hint Settings, then assign it on your RuntimeSpawner (enable Use Spawn Hints).

What it does

When enabled, the locator first looks for nearby hint points (per wave/region/global query). Each candidate is checked against distance rules, optional line-of-sight, and (if needed) NavMesh projection. A short reservation prevents piling multiple spawns onto the same hint during bursts. If no hint qualifies and Hint-Only is off, the system falls back to the normal sampler.

Properties

Top-level behavior

  • Hint-Only (no fallback) If ON, spawns are skipped unless a suitable hint is found. Use this when you’ve authored hint points and never want random placement.

  • Ignore Spawner’s Global Min Range If ON (and especially useful with Hint-Only), the global Min Spawn Range on the RuntimeSpawner is ignored when validating hints. This prevents a common setup issue where Min Spawn Range (e.g., 25m) blocks hints you’ve placed closer to the player (e.g., 5–15m).

Spatial Index

  • Cell Size Grid bucket size for the internal hint registry. Larger cells = fewer buckets (faster inserts, broader lookup). Smaller cells = tighter spatial queries.

Query Defaults

  • Wave Search Padding Extra meters added to a wave’s spawn radius when searching for hints near its anchor(s).

  • Region Search Padding Extra meters added around a region’s bounds when searching for hints.

  • Global Search Fraction Builds the global search radius as CullDistance × Fraction. (e.g., 0.75 with 100m cull ⇒ 75m hint radius.)

Placement

  • NavMesh Sample Max Dist How far to probe when snapping a hint to the NavMesh (for hints or entries that require it).

  • LOS Block Mask Physics layers that block line-of-sight. If a hint’s denyLineOfSight is true, the locator rejects it when the player can see it.

  • Reservation Seconds Soft cooldown applied to a hint after use so back-to-back spawns don’t all stack there.

  • Prefer Scoped First Prioritize hints within the local scope (wave/region) before considering broader/global hints.

  • Max Hint Attempts Upper bound on how many hint candidates the locator will evaluate per query to keep work predictable.

Note: Hint-specific rules (set on the EnemySpawnHintPoint component) include Min/Max Player Distance, Deny Line Of Sight, Require NavMesh, and Override Area Mask. These run per candidate in addition to the global settings above.


How the query works (simplified)

  1. Build a search circle (wave/region/global) using your paddings/fraction.

  2. If the wave provided anchor tags, first pass tries hints that match any of those tags.

  3. For each candidate hint (respecting Max Hint Attempts):

    • Validate distance to player (respecting Ignore Spawner’s Global Min Range when ON).

    • If hint requires LOS denial and the player can see it, reject.

    • If hint requires NavMesh, try NavMesh.SamplePosition (respecting hint’s Override Area Mask, otherwise the spawner’s mask).

    • Reserve the hint for Reservation Seconds and return the position.

  4. If no hint qualified:

    • With Hint-Only OFF ⇒ fall back to the usual sampler.

    • With Hint-Only ON ⇒ skip the spawn.


Presets (quick starting points)

(These match the preset buttons in the inspector.)

  • Conservative: Cell 24, Wave/Region Pad 2, Global 0.5, NavMax 25, Reserve 1.2s, Attempts 8, Prefer Scoped ✓

  • Balanced: Cell 16, Wave/Region Pad 4, Global 0.75, NavMax 35, Reserve 1.0s, Attempts 16, Prefer Scoped ✓

  • Aggressive: Cell 12, Wave/Region Pad 6, Global 0.9, NavMax 42, Reserve 0.6s, Attempts 24, Prefer Scoped ✓


Best practices

  • Place 2–5 hints per tile or encounter space (corners, cover pockets, flanks).

  • Use Deny Line Of Sight to prevent pop-in near the player’s gaze.

  • Give close-quarters hints a Min Player Distance (e.g., 6–10m) so they won’t fire when the player is on top of them.

  • For grounded AI on uneven areas, set hint Require NavMesh so the position snaps cleanly to walkable.


Troubleshooting

  • “Nothing spawns with Hint-Only”

    • Your hints may all be too close (below spawner’s Min Spawn Range). Turn ON Ignore Spawner’s Global Min Range, or reduce either the spawner’s Min Spawn Range or the hint’s Min Player Distance.

    • Hints may be too far (over their Max Player Distance). Lower that, or move closer.

    • Hints with Require NavMesh may be failing to project (increase NavMesh Sample Max Dist or loosen Area Mask on the entry/hint).

    • If waves specify anchor tags, ensure at least one hint shares a tag (or clear tags to accept any).

  • Spawns pile onto the same hint Increase Reservation Seconds or add a few more hints in that pocket.

  • Performance If you have hundreds of hints, keep Max Hint Attempts reasonable (8–24) and start with Cell Size 12–24.


Quick setup

  1. Create a Spawn Hint Settings asset and assign it on your RuntimeSpawner.

  2. Toggle Use Spawn Hints; use Hint-Only if you want strictly authored placements.

  3. Drop EnemySpawnHintPoint components into your tiles and tune distances/LOS per point.

  4. Hit Play and tweak Wave/Region Padding, Global Fraction, and Reservation until spawns feel natural.

Last updated