ParticleEmitter
ParticleEmitter manages a Tier 2 (Jolt physics) particle system. Each particle is a Jolt dynamic body that collides with the world. Particles are rendered via InstancedMesh internally. Create via Scene.createParticleEmitter.
Creating an emitter
Section titled “Creating an emitter”scene.createParticleEmitter(name, maxBodies, size, mass, lifetime, emissionRate, x, y, z)
Section titled “scene.createParticleEmitter(name, maxBodies, size, mass, lifetime, emissionRate, x, y, z)”Returns: ParticleEmitter — A new emitter registered with the scene.
Parameters:
name(String) — Identifier for this emitter.maxBodies(Num) — Maximum particle pool size (number of simultaneous physics bodies).size(Num) — Particle size in metres.mass(Num) — Particle mass in kg.lifetime(Num) — Particle lifetime in seconds.emissionRate(Num) — Particles emitted per second.x,y,z(Num) — Initial emitter position.
_emitter = _scene.createParticleEmitter("sparks", 128, 0.05, 0.1, 2.0, 50, 0, 3, 0)Emitters can also be loaded automatically from .blend particle systems when instantiating with Resource.loadBlend.
Playback control
Section titled “Playback control”| Method | Description |
|---|---|
play() | Start emitting particles continuously at emissionRate. |
stop() | Stop emitting new particles (existing ones continue until their lifetime expires). |
pause() | Pause all simulation (freeze existing particles in place). |
resume() | Resume from a paused state. |
burst(count) | Immediately spawn count particles at the emitter position, ignoring emission rate. |
_emitter.play()
// On explosion:_emitter.burst(64)Properties
Section titled “Properties”| Property | Returns | Description |
|---|---|---|
isPlaying | Bool | true if emitting (not stopped or paused) |
isPaused | Bool | true if paused |
activeCount | Num | Current live particle count |
maxBodies | Num | Maximum pool size (set at creation) |
name | String | Emitter name |
emissionRate=(rate) | — | Set particles per second |
Emitter position & orientation
Section titled “Emitter position & orientation”setPosition(x, y, z)
Section titled “setPosition(x, y, z)”Move the emitter origin. New particles spawn from this position.
setNormal(nx, ny, nz)
Section titled “setNormal(nx, ny, nz)”Set the emission direction normal. Particles are given initial velocity along this direction (plus any random/tangential factors configured in the blend).
// Follow a nodevar pos = _nozzleNode.getWorldPosition()_emitter.setPosition(pos[0], pos[1], pos[2])
var fwd = _nozzleNode.getForward()_emitter.setNormal(fwd[0], fwd[1], fwd[2])Custom mesh
Section titled “Custom mesh”setMeshFromNode(node)
Section titled “setMeshFromNode(node)”Use the mesh from a Node to render particles instead of the default sphere.
_emitter.setMeshFromNode(_sparkMeshNode)See InstancedMesh for non-physics GPU instancing. See Scene for createParticleEmitter. See Physics for body configuration details (collision layers in game.toml apply to particle bodies).