Spawner Plugin | Solarnaut Studios

← Back

Contents

Plugin Overview

v 1.0

The Solarnaut Spawner plugin offers developers a robust, reliable implementation for spawning gameplay relevant objects at runtime.

At the core is the Subsystem, which manages all of the Spawners. Spawners are defined by their Definition Table, Conditions, Triggers, LocationProviders, and Contexts. There is also built-in handling for Telegraphing spawns.

Please note that comments found in the source code contain more detail and should be considered correct anywhere it may conflict with this documentation.


Subsystem

The Spawner Subsystem (USolSpawnerSubsystem) knows about all spawners and all spawned actors in the world. The Subsystem has a queue for spawners waiting to spawn actors, maintains maps of all relevant information, sends actor death notifications, and broadcasts gameplay requests for spawning to all relevant spawners (via BroadcastTriggerPayload).

The simplest payload to broadcast is just a GameplayTag, and the simplest thing for a spawner to do is see if it wants to respond to that Tag or not (using its triggers). However, the system is open-ended, using USolCustomPayload as a way to pass any arbitrary data around.


Spawners

ASolSpawnerBase is the concrete base class for all spawners, which can be Blueprinted. It has a set of features that should be useful in many situations, but new native classes can also extend or override core functionality when necessary.

Basic Features


Spawn Telegraphs

Any Actor class or Blueprint can implement SolSpawnTelegraphInterface, which consists of one function: SetTelegraphDuration(float InSeconds). The spawner can set its own class and duration, but Spawn Definitions can provide their own. The TelegraphOverride field specifies how to choose the correct telegraph actor and time. The bOneTelegraph field enforces only a single telegraph's appearance (at the location of the first spawned actor), but its delay will apply to the entire group of actors spawned.


Spawn Triggers

USolSpawnTrigger is the abstract base class for all triggers, which can be Blueprinted. Initialized in their spawner’s BeginPlay, they have two main ways of activating. The first is DoesPayloadMatch, called from the Subsystem’s BroadcastTriggerPayload. This is the most flexible way to send events to triggers, and each trigger can determine if they care to respond to it or not. If they want to respond, they activate using FireTrigger. The other main activation method is calling FireTrigger directly, but it is recommended to broadcast through the Subsystem whenever possible.

Triggers are components, so must be added via the spawner’s component list.

Included Triggers

FireTrigger always calls CanFireTrigger first to ensure the trigger hasn’t hit its MaxTriggerCount and that its Spawner is Armed. The provided trigger classes also gate DoesPayloadMatch with CanFireTrigger so that they only count while “active”.

Triggers may continue tracking while the spawner is disarmed, then fire immediately once it is re-armed (if it wants to).


Spawn Location Providers

USolSpawnLocationProvider is the abstract base class for all location providers, which can be Blueprinted. Each provider implements GetSpawnTransforms (in C++ or Blueprint). Points returned by the provider can be adjusted to find a suitable ground location automatically (with configurable options for raycasting and/or navmesh projection).

Location providers are components, so must be added to a spawner’s component list.

Included Location Providers


Spawn Definitions

FSolSpawnDefinition specifies what will be spawned: an AActor derived class, GameplayTags to identify the definition, a Weight to use when picking multiple definitions, and an optional Telegraph Actor class. This struct is used to create DataTable assets. There can be one table per spawner, or a table can be shared across as many spawners as desired.


Spawn Conditions

USolSpawnCondition is a simple object that can filter a Spawn Definition’s Actor class or GameplayTags. Spawners have their own list of conditions. Triggers can also define their own list of conditions, so that a spawner with multiple triggers might only be able to spawn a particular actor from one of those triggers. All conditions must pass for a definition to be eligible.


Spawn Contexts

USolSpawnContext is the abstract base class for contexts. A spawn context typically modifies a spawned actor in some way, though it isn’t required to. Contexts can be configured on Spawners and Triggers, and sent in payloads.

Included Contexts


First Implementation Steps

  1. Create a new DataTable using SolSpawnDefinition.
  2. Configure it with at least one row, e.g. set the ActorClass to a character BP.
  3. Place a Solarnaut Spawner in the level.
  4. Set its SpawnDefinitionTable to the one created in step 1.
  5. Add a Begin Play Trigger to the spawner.
  6. Press Play!
  7. One of the actors in the DataTable will spawn at the spawner’s location.

Console Commands

Play-in-Editor Testing