Table of Contents

,

Start Page » DragonScript Scripting Language » Abstraction Layers: How you want to build your Game » Behavior Elements » ECBehaviorParticleEmitter

ECBehaviorParticleEmitter

Behavior element behavior adding particle emitter support.

Behavior adds a ParticleEmitter resource to the the behavior element.

If the ECBehaviorCollider behavior is present in the behavior element before this behavior is added the particle emitter is attached. The particle emitter is attached to the named bone if defined otherwise it is attached statically.

See also:

Instance Counts

This behavior can be added multiple times to an element. Each instance creates one particle emitter attached to the element collider which can be individually modified.

Element Class Properties

Element class properties have the prefix particleEmitter. or particleEmitter({id}). if id is not empty.

path

Set path to particle emitter resource to use.

timeScale

Set time scale for controllers advanced by time.

warmUpTime

Set warm up time in seconds. If larger than 0 particle emitter starts with particles already simulated this many seconds.

casting

Set particle emitter is casting particles.

position

Set position to attach resource to collider.

orientation

Set orientation to attach resource to collider in degrees.

bone

Set bone to attach resource to. If empty string attach to collider.

trigger

Set trigger casting. If no trigger is set the state of casting property is used.

targetCasting

Set target casting. Fires target start casting and resets target if stop casting. Target can be used in triggers.

targetLastParticleDied

Set target last particle died. Pulses target if the last particle died. This happens a certain amount of time after targetCasting has been reset. Target can be used in triggers.

Events

This behavior provides these events:

startCasting

Start casting particles.

stopCasting

Stop casting particles.

lastParticleDied

Last particle of a burst emission died.

particleResponse

Determine response for a custom particle collision.

Listener can update provided collisionInfo with the particle response to use. Multiple listeners can potentially update collisionInfo. The last update is used. If no listener updates the information the particle will be destroyed.

Required Behaviors

This behavior requires no other behaviors.

Optional Behaviors

Persistency

This behavior does support element class to be persistable (setPersistable). Saves selected color.

API Documentation

ECBehaviorParticleEmitter.

Since DragonScript Module Version 1.0

Use Cases

Element Class Example

This example defines an element which contains a particle emitter.

class MyElement extends BehaviorElementClass
  public var ECBehaviorComponent component
  public var ECBehaviorCollider collider
  public var ECBehaviorParticleEmitter particleEmitter
  func new()
    component = ECBehaviorComponent.new(this, null)
    collider = ECBehaviorCollider.new(this, component)
    particleEmitter = ECBehaviorParticleEmitter.new(this, collider)
    particleEmitter.getParticleEmitter().getParticleEmitter().setPath("/content/emitters/water.depemit")
  end
end

Behavior Factory

Using element class supporting adding behaviors the behavior can be added like this:

<?xml version='1.0' encoding='UTF-8'?>
<elementClass name='MyClass' class='GenericBehaviorElement'>
  <behavior type='ECBehaviorComponent'/>
  <behavior type='ECBehaviorCollider'/>
 
  <behavior type='ECBehaviorParticleEmitter'>
    <!-- optional: set collision filter. default value '5:0 1 2 6' which means
                   category BaseGameApp.CollisionFilterBit.particle
                   filter BaseGameApp.CollisionFilterBit.geometry,
                          BaseGameApp.CollisionFilterBit.dynamic,
                          BaseGameApp.CollisionFilterBit.actor,
                          BaseGameApp.CollisionFilterBit.forceField.
                   format is '', 'category' or 'category:filter' where category and filter
                   are a list of bits to set. -->
    <string name='collisionFilter'>5:0 1 2 6</string>
 
    <!-- optional: use BaseGameApp trigger table. game can add more supported values.
                   default value is 'default'. -->
    <string name='triggerTable'>default</string>
 
    <!-- optional: sync trigger with particle emitter matching identifier -->
    <string name='syncTrigger'>second</string>
 
    <!-- set element properties. omit property prefix if used inside behavior tag -->
    <string name='.path'>water.depemit</string>
  </behavior>
 
  <!-- for adding multiple behaviors use unique identifiers -->
  <behavior type='ECBehaviorParticleEmitter' id='second'/>
</elementClass>

Live Examples