codeAPI Reference
s&box EmitterEntity: Particle emitter entity
EmitterEntity Component API Reference
EmitterEntity is a world-placed SENT that spawns and controls a particle/VFX emitter. The emitter prefab is defined by a ScriptedEmitter resource. It implements IPlayerControllable for player input.
Type Signature
CSHARP
[Alias("emitter")]
public class EmitterEntity : Component, IPlayerControllable
{
[Property, ClientEditable]
public ScriptedEmitter Emitter { get; set; }
[Property, ClientEditable]
public EmitMode Mode { get; set; } = EmitMode.Toggle;
[Property, Sync, ClientEditable, Group("Input")]
public ClientInput ToggleInput { get; set; }
[Property, Sync, ClientEditable, Group("Input")]
public ClientInput HoldInput { get; set; }
[Sync]
public bool IsEmitting { get; private set; }
[Property, ClientEditable]
public bool ManualOn { get; set; }
}Properties
- ScriptedEmitter Emitter { get; set; } - The emitter definition pointing to a prefab containing a particle system
- EmitMode Mode { get; set; } = EmitMode.Toggle - Whether emitter toggles on/off or emits while held
- ClientInput ToggleInput { get; set; } - Input for Toggle mode
- ClientInput HoldInput { get; set; } - Input for Hold mode
- bool IsEmitting { get; private set; } - Whether emitter is currently active (synced)
- bool ManualOn { get; set; } - Forces emitter on regardless of input or mode
IPlayerControllable Implementation
- OnControl() - Handles Toggle or Hold input based on Mode
- OnStartControl() - Empty
- OnEndControl() - Resets input state in Hold mode
Usage
CSHARP
// Create an emitter that toggles on/off
var emitter = GameObject.Components.Create<EmitterEntity>();
emitter.Emitter = myEmitterResource;
emitter.Mode = EmitMode.Toggle;
emitter.ManualOn = true; // Force onNotes
- Alias is "emitter" for spawning via console
- Spawns particle instance as child when IsEmitting becomes true
- Destroys particle instance when IsEmitting becomes false
- ManualOn overrides input state
- IsEmitting is synced via RPC.Broadcast
- Particle instance is recreated if Emitter resource changes
Was this helpful?