codeAPI Reference

s&box EntitySpawnerEntity: Entity spawner

calendar_today May 12, 2026 schedule ~1 min read person PatrickJr verified 50

EntitySpawnerEntity Component API Reference

EntitySpawnerEntity is a world-placed SENT that spawns another SENT at its location. Can be triggered manually via player input or automatically on a timer. Implements IPlayerControllable.

Type Signature

CSHARP
[Alias("entity_spawner")]
public class EntitySpawnerEntity : Component, IPlayerControllable
{
    [Property, ClientEditable]
    public ScriptedEntity Entity { get; set; }

    [Property, Sync, ClientEditable, Group("Input")]
    public ClientInput SpawnInput { get; set; }

    [Property, ClientEditable, Group("Auto Spawn")]
    public bool AutoSpawn { get; set; } = false;

    [Property, ClientEditable, Range(1f, 300f), Step(1), Group("Auto Spawn")]
    public float SpawnInterval { get; set; } = 5f;

    [Property, ClientEditable, Range(1, 50), Step(1), Group("Auto Spawn")]
    public float MaxEntities { get; set; } = 5;
}

Properties

IPlayerControllable Implementation

Usage

CSHARP
// Create an auto-spawning entity spawner
var spawner = GameObject.Components.Create<EntitySpawnerEntity>();
spawner.Entity = myEntityResource;
spawner.AutoSpawn = true;
spawner.SpawnInterval = 10f;
spawner.MaxEntities = 10;

Notes

  • Alias is "entity_spawner" for spawning via console
  • Auto-spawn only runs on host (IsProxy check)
  • Tracks spawned entities with WeakReference to enforce MaxEntities limit
  • Prunes destroyed entities from tracking list each spawn
  • Spawned entities are tagged "removable"
  • Ownership is set to caller or GameObject owner
  • Undo entry is created for the spawning player
  • Spawned entities are networked and enabled after spawn
Was this helpful?