Skip to content

MovementBehavior<DataType, ParticleType>

Behavior used to control particle movement over their lifetime.

This behavior supports two configuration modes, either by specifying minimum and maximum movement speeds for the X and Y axes, or by providing list data to define movement values over the particle's lifetime.

See

Example

ts
// Configure movement using min/max speeds.
movementBehavior.applyConfig({
    minMoveSpeed: { x: -50, y: -100 },
    maxMoveSpeed: { x: 50, y: 100 },
    mode: "linear",
    space: "global",
});

// Configure movement using lists.
movementBehavior.applyConfig({
    xListData: {
        list: [
            { time: 0.0, value: 0 },
            { time: 1.0, value: 100 },
        ],
    },
    yListData: {
        list: [
            { time: 0.0, value: 0 },
            { time: 1.0, value: -100 },
        ],
    },
    mode: "acceleration",
    space: "local",
});

Extends

Type Parameters

DataType

DataType extends BaseParticleData

Type describing the data object stored on particles.

ParticleType

ParticleType extends IEmitterParticle<DataType> = IEmitterParticle<DataType>

Type describing the particle used within the emitter.

Implements

Constructors

Constructor

ts
new MovementBehavior<DataType, ParticleType>(emitter): MovementBehavior<DataType, ParticleType>;

Creates new instance of MovementBehavior.

Parameters

emitter

Emitter<DataType, ParticleType>

Emitter instance this behavior belongs to.

Returns

MovementBehavior<DataType, ParticleType>

Overrides

EmitterBehavior.constructor

Accessors

maxMoveSpeed

Get Signature

ts
get maxMoveSpeed(): PointData;

Maximum movement speed (used when not using lists).

Returns

PointData

Set Signature

ts
set maxMoveSpeed(value): void;
Parameters
value

PointData

Returns

void


minMoveSpeed

Get Signature

ts
get minMoveSpeed(): PointData;

Minimum movement speed (used when not using lists).

Returns

PointData

Set Signature

ts
set minMoveSpeed(value): void;
Parameters
value

PointData

Returns

void


mode

Get Signature

ts
get mode(): "linear" | "acceleration";

Movement mode currently used by the behavior.

Returns

"linear" | "acceleration"

Set Signature

ts
set mode(value): void;
Parameters
value

"linear" | "acceleration"

Returns

void


space

Get Signature

ts
get space(): "local" | "global";

Space in which movement is applied.

Returns

"local" | "global"

Set Signature

ts
set space(value): void;
Parameters
value

"local" | "global"

Returns

void


updateOrder

Get Signature

ts
get updateOrder(): BehaviorOrder;

Defines at which step of the update cycle the behavior is applied.

  • initial: Earliest step, useful when other behaviors depend on this behavior.
  • normal: Default step for most behaviors.
  • late: Latest step, useful for behaviors that should override others or depend on their properties.
Returns

BehaviorOrder

Implementation of

UpdateBehavior.updateOrder

Overrides

EmitterBehavior.updateOrder


useList

Get Signature

ts
get useList(): boolean;

Whether to use list-based movement configuration.

Returns

boolean

Set Signature

ts
set useList(value): void;
Parameters
value

boolean

Returns

void


xList

Get Signature

ts
get xList(): NumberList;

Number list used to interpolate X-axis movement values over particle lifetime.

A behavior will always have a list, even when not using list-based configuration, but the list might not be initialized and will be empty in that case.

Returns

NumberList


yList

Get Signature

ts
get yList(): NumberList;

Number list used to interpolate Y-axis movement values over particle lifetime.

A behavior will always have a list, even when not using list-based configuration, but the list might not be initialized and will be empty in that case.

Returns

NumberList

Methods

applyConfig()

ts
applyConfig(config): void;

Reset the behavior and apply the provided configuration.

Parameters

config

MovementBehaviorConfig

Behavior configuration.

Returns

void

Implementation of

UpdateBehavior.applyConfig

Overrides

EmitterBehavior.applyConfig


getConfig()

ts
getConfig():
  | MovementBehaviorConfig
  | undefined;

Retrieve the current behavior properties as a configuration object. If the behavior is inactive, undefined is returned.

Returns

| MovementBehaviorConfig | undefined

Behavior configuration object or undefined if inactive.

Implementation of

UpdateBehavior.getConfig

Overrides

EmitterBehavior.getConfig


init()

ts
init(particle): void;

Initialize the particle.

Parameters

particle

ParticleType

Particle to initialize.

Returns

void

Implementation of

InitBehavior.init


reset()

ts
protected reset(): void;

Reset the behavior to its default state.

Returns

void

Implementation of

UpdateBehavior.reset

Overrides

EmitterBehavior.reset


update()

ts
update(particle, deltaTime): void;

Updates the particle.

Parameters

particle

ParticleType

Particle to update.

deltaTime

number

Time elapsed since the last update, in seconds.

Returns

void

Implementation of

UpdateBehavior.update