Wave Spawnpoint

A WaveSpawnPoint is a simple spatial anchor used by Waves (and Specials) to direct where units should appear. Each point provides:

  • A center position in the world

  • A Spawn Range (radius) for randomization around that point

  • Optional Anchor Tags to describe the intent of the spot (e.g., Flank, Ambush, Far)

Wave Triggers can hold a list of these points and will choose one at spawn time.

Adding Wave Spawn Points

  • Menu: GameObject → Runtime Spawner → Create Wave Spawn Point This creates a point near the SceneView camera. If an object is selected, the new point is parented to it (handy for organizing under a Wave Trigger).

  • Or manually: Create an empty GameObject and add WaveSpawnPoint.

If you’re using a Wave Trigger, make sure your points are referenced in the trigger’s Wave Spawn Points list (visible on the Wave Trigger component). When a wave fires, one of these points is picked and used as the anchor.

Inspector (WaveSpawnPoint)

  • Spawn Range Radius (in meters) around this point where the actual spawn position will be sampled. Larger values create more dispersed spawns; smaller values keep spawns tight to the anchor.

  • Anchor Tags A list of semantic tags describing the spot (e.g., Flank, Ambush, HighGround). These tags are forwarded to the placement system so it can prefer matching Spawn Hints (see below).

Gizmos: In the Scene view, WaveSpawnPoint draws a small sphere at its position and a wire circle for the Spawn Range (color is configurable via Runtime Spawner Settings).

How it fits into Wave Triggers & Waves

  1. A Wave Trigger has a list of WaveSpawnPoint references (its “anchors”).

  2. When a wave starts, the system:

    • Picks one of the trigger’s anchors

    • Uses the anchor’s position and Spawn Range to define a search area

    • (If Spawn Hints are enabled) passes the anchor’s Anchor Tags to the hint system to preferentially choose matching hint points

    • Resolves a final NavMesh-valid position and spawns there

If no WaveSpawnPoint is assigned, the system falls back to the trigger transform (with a small default range).

Using with Spawn Hints (optional)

If Use Spawn Hints is enabled on the Runtime Spawner:

  • The anchor’s Anchor Tags are provided to the hint query. The system first tries to use EnemySpawnHintPoint markers that share any of these tags. If none match, it will try any eligible hint in range.

  • If Hint-Only is enabled in Spawn Hint Settings, and no suitable hint is found, the spawn is skipped (no fallback).

Tips

  • Place multiple WaveSpawnPoints around an encounter pocket: entrances, flanks, behind cover, etc.

  • Use Anchor Tags that match the semantics of nearby EnemySpawnHintPoint (e.g., both use Flank) to get predictable, authored results.

  • Keep Spawn Range reasonable—large enough to avoid stackups, small enough to maintain encounter shape.

  • Remember global constraints still apply (e.g., Minimum Spawn Range to the player unless your Spawn Hint Settings explicitly ignore it).

Fundamentals

WaveSpawnPoint represents a spatial anchor used by WaveTrigger and SpecialEncounterManager to direct where spawned units should appear. Each spawn point provides a world position, an optional spawn radius, and a set of semantic tags that allow wave entries or special encounter rules to filter or select anchors dynamically.

These anchors make it possible to author controlled encounters such as:

  • Flanking waves

  • Ambush points

  • Multi-lane assault points

  • Boss arena entry positions

  • Spawn clusters using variable radii


Responsibilities

  • Provide a world-space location for wave or special spawning.

  • Define an optional spawn radius for distributing units around the anchor.

  • Expose semantic tags to classify points (“Flank”, “Ambush”, “HighGround”, etc.).

  • Draw authoring gizmos in the Scene view for visual clarity.

The spawn radius and tags can be read by the wave system to determine placement rules, filtering, or selection logic.


Key Properties

Spawn radius

public float GetSpawnpointRange()

Returns the radius in world units that waves or specials may use to distribute units around this anchor. A radius of 0 indicates the point should be treated as a single position.

Semantic tags

public string[] AnchorTags

Returns the anchor’s semantic tags. Common uses include:

  • Restricting a wave entry to only spawn at anchors tagged "Ambush".

  • Choosing between “Near”, “Far”, or “Flank” positions.

  • Allowing special encounters to pick from designated lanes or categories.

Tags are user-defined and fully author-controlled.


Inspector Fields

range

  • World-space radius used for spawning.

  • The wave system may spawn units anywhere inside this radius.

  • Default: 6.0f.

  • Clamped internally to non-negative values.

anchorTags

  • Optional list of tags providing semantic meaning to this anchor.

  • Used by wave entries or special encounters to filter or bias anchor selection.

  • Defined as an array of strings in the inspector.


Editor Helpers

In the editor, the following helpers are available:

public void SetRange(float r)

Sets the spawn radius (editor-only).

public void SetAnchorTags(string[] tags)

Assigns semantic tags (editor-only).

These methods are intended for tooling and custom inspectors rather than runtime use.


Gizmos

When viewing the scene in the editor:

  • A small sphere is drawn at the spawn point position.

  • A wireframe circle/sphere shows the effective spawn radius.

  • Gizmo colors are pulled from RuntimeSpawnerSettings.waveSpawnpointColor.

Spawn points are typically children of WaveTrigger GameObjects for organizational clarity.


Typical Usage Patterns

1. Basic placement of spawn anchors

To add spawn anchors for a wave:

  1. Select a WaveTrigger in the hierarchy.

  2. Use the Add Spawnpoint button from the trigger’s inspector (editor-only).

  3. Position the new WaveSpawnPoint transform at the desired location.

  4. Adjust the range and assign any semantic anchorTags.

When the wave activates, spawned units will be positioned relative to the selected anchor.


2. Using tags to direct wave behavior

Wave entries can filter anchor points based on tag matching (configuration-driven or code-driven, depending on project setup).

Example setup:

  • Create multiple anchors under a WaveTrigger:

    • One tagged "Flank"

    • One tagged "Ambush"

    • One untagged baseline point

In your wave configuration, choose anchors based on tags to produce different encounter styles:

  • Early waves use "Flank"

  • Mid waves use "Ambush"

  • Final waves use all available anchors

This provides a structured and deterministic method to control wave direction and difficulty pacing.


3. Adjusting spawn radius for encounter style

The spawn radius can influence the density or feel of a wave:

  • Small radius (1–2 m): tight ambushes or clustered spawns.

  • Larger radius (6–12 m): dispersed mobs or multi-directional entry points.

  • Very large radius (15+ m): arena-scale distribution for boss encounters.

Example:

public class ModifyAnchorRadius : MonoBehaviour
{
    [SerializeField] private WaveSpawnPoint anchor;

    public void WidenArea()
    {
        anchor.SetRange(12f);   // For more dispersed spawning
    }

    public void TightenArea()
    {
        anchor.SetRange(2f);    // For close-range surprise spawns
    }
}

4. Creating wave spawn points procedurally

Spawn points can be instantiated at runtime when creating dynamic arenas:

using UnityEngine;
using MegaCrush.Spawner;

public class DynamicAnchorBuilder : MonoBehaviour
{
    public WaveSpawnPoint CreateAnchor(Vector3 position, float radius, string[] tags)
    {
        var go = new GameObject("Procedural SpawnPoint");
        go.transform.position = position;

        var anchor = go.AddComponent<WaveSpawnPoint>();
#if UNITY_EDITOR
        anchor.SetRange(radius);
        anchor.SetAnchorTags(tags);
#endif
        return anchor;
    }
}

This is useful for procedural levels, dynamic encounter pacing, or adaptive AI systems.


5. Visualizing encounter layout in the editor

With multiple WaveSpawnPoint anchors placed:

  • Move each anchor to illustrate where enemies can appear.

  • Adjust the radius to tune encounter size.

  • Assign tags to define spatial semantics.

  • Use the trigger’s editor gizmo toggle to visualize boundaries and flow.

Combined with WaveTrigger gizmos, these anchors provide a clear authoring workflow for structured encounter design.

Last updated