Skip to content

Particle Systems

Particle effects are represented by SgParticles scene objects. Most particle authoring happens in the Studio editor; scripts control playback, parameters, and spawning at runtime.

Overview

See Particle System for the editor workflow, emitter types, and simulation concepts.

Creating from script

local SgParticles = require 'engine/sceneobjects/particles'
local Transform = require 'engine/math/transform'
local Vector3 = require 'engine/math/vector3'

local fx = await(SgParticles.create({
    name = "Explosion",
    transform = Transform.new(Vector3.new(0, 1, 0)),
    -- particle system item / fields as configured in datatype
}))

Link a particle system item via Property.Link when the effect is pre-authored in the project.

Runtime control

Scripts on or referencing the particle object typically:

  • Enable/disable the object with setActive
  • Move the emitter with withTransform or translate
  • Toggle preview or simulation flags exposed as scene object fields

Consult SgParticleSystem for scriptable fields and methods generated from the Lua API.

Spawning one-shot effects

For explosions and hits, spawn a prefab or SgParticles instance, let it play, then delete() or return to a pool when finished (see Prefabs).

Further reading