Untitled

📰Getting Started | **Updates |** 📝 Guides | 🔢 API | ❓FAQ

Guides Overview

The Particles API is available on any element that contains an asset with an underlying Unity Partical System.

if (!this.particles) {
    log.error('Asset does not contain a ParticleSystem!');
return;
}

Emission

Particle emission can be driven through the scripting API.

// Emit 10 particles.
this.particles.emit(10);

// Configure particles to emit when a bool schema value changes.
this.particles.emitOn('active', 5);

// Cleanup when the subscription is no longer needed.
this.particles.emitOff('active');

The underlying particle system's maximum particle count will still control the overall system and may not show all particles created through scripting.

External Forces

External Forces allows emitted particles to be influenced by other particle fields nearby.

// Limit the systems influences by another Element.
var field =this.findOne('..(@name=Field)');
this.particles.externalForces.addLimit(field);

//Remove an Element as a limit.
this.particles.externalForces.removeLimit(field);

// Clear all limits from a system's influence list.
this.particles.externalForces.clearLimits();

An Element must contain a Particle System Force Field component from Unity to be added as a limit.

Module Properties

externalForces <ExternalForces>

Wrapper for external forces parameters.

Module Methods

emit(count)

Emits particles immediately.

emitOn(key, count)

Emits particles when a boolen parameter is set to true.

emitOff(key)

Stop listening to a schema key.

ExternalForces Properties

enabled <bool>

Whether the effect is active or not.

ExternalForces Methods

addLimit(widget)

Attempts to add another element as an influencer to the system.

removeLimit(widget)

Removes an element acting as an influencer in the system.

clearLimits()

Clears the list of influencers in the particle system.

Next: Physics

Sidebar Table of Contents


Untitled

Copyright © 2021 Enklu, Inc.