Options
All
  • Public
  • Public/Protected
  • All
Menu

A particle that follows a path defined by an algebraic expression, e.g. "sin(x)" or "5x + 3". To use this class, the behavior config must have a "path" string or function.

A string should have "x" in it to represent movement (from the speed settings of the behavior). It may have numbers, parentheses, the four basic operations, and any Math functions or properties (without the preceding "Math."). The overall movement of the particle and the expression value become x and y positions for the particle, respectively. The final position is rotated by the spawn rotation/angle of the particle.

A function merely needs to accept the "x" argument and output the a corresponding "y" value.

Some example paths:

  • "sin(x/10) * 20" A sine wave path.
  • "cos(x/100) * 30" Particles curve counterclockwise (for medium speed/low lifetime particles)
  • "pow(x/10, 2) / 2" Particles curve clockwise (remember, +y is down).
  • (x) => Math.floor(x) * 3 Supplying an existing function should look like this

Example configuration:

{
"type": "movePath",
"config": {
"path": "round(sin(x) * 2",
"speed": {
"list": [{value: 10, time: 0}, {value: 100, time: 0.25}, {value: 0, time: 1}],
},
"minMult": 0.8
}
}

Hierarchy

  • PathBehavior

Implements

Index

Constructors

  • new PathBehavior(config: { minMult: number; path: string | ((x: number) => number); speed: ValueList<number> }): PathBehavior
  • Parameters

    • config: { minMult: number; path: string | ((x: number) => number); speed: ValueList<number> }
      • minMult: number

        A value between minimum speed multipler and 1 is randomly generated and multiplied with each speed value to generate the actual speed for each particle.

      • path: string | ((x: number) => number)

        Algebraic expression describing the movement of the particle.

      • speed: ValueList<number>

        Speed of the particles in world units/second. This affects the x value in the path. Unlike normal speed movement, this can have negative values.

    Returns PathBehavior

Properties

list: PropertyList<number>
minMult: number
order: BehaviorOrder = BehaviorOrder.Late

Order in which the behavior will be handled. Lower numbers are handled earlier, with an order of 0 getting special treatment before the Emitter's transformation is applied.

path: (x: number) => number

Type declaration

    • (x: number): number
    • The function representing the path the particle should take.

      Parameters

      • x: number

      Returns number

editorConfig: BehaviorEditorConfig = null
type: string = 'movePath'

Methods

  • updateParticle(particle: Particle, deltaSec: number): void

Generated using TypeDoc