{{tag>dragonscript behavior}}
[[:start|Start Page]] >> [[main|DragonScript Scripting Language]] >> [[dragengine:modules:dragonscript:abstractions|Abstraction Layers: How you want to build your Game]] >> [[dragengine:modules:dragonscript:behavior_elements|Behavior Elements]] >> **ECBehaviorParticleEmitter**
* [[behaviors_use_cases|Behaviors Explained: By Use-Case]]
* [[behaviors_a_to_z|Behaviors Explained: From A to Z]]
====== ECBehaviorParticleEmitter ======
Behavior element behavior adding particle emitter support.
Behavior adds a ParticleEmitter resource to the the behavior element.
If the [[behavior_collider|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:
* [[gamedev:particleemitters|Particle Emitters]]
* [[gamedev:deigde:editors:particleemitter|IGDE Particle Emitter Editor]]
====== 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.
* Full name: ''particleEmitter.path'' or ''particleEmitter({id}).path''
* Type: string
* Default Value: empty string
* Expected File Pattern: ''*.depemit''
* Example (*.deeclass) fire.depemit
===== timeScale =====
Set time scale for controllers advanced by time.
* Full name: ''particleEmitter.timeScale'' or ''particleEmitter({id}).timeScale''
* Type: float
* Default Value: 1
* Example (*.deeclass) 0.5
===== warmUpTime =====
Set warm up time in seconds. If larger than 0 particle emitter starts with particles already simulated this many seconds.
* Full name: ''particleEmitter.warmUpTime'' or ''particleEmitter({id}).warmUpTime''
* Type: float
* Default Value: 0
* Example (*.deeclass) 2
===== casting =====
Set particle emitter is casting particles.
* Full name: ''particleEmitter.casting'' or ''particleEmitter({id}).casting''
* Type: boolean
* Default Value: true
* Example (*.deeclass) false
===== position =====
Set position to attach resource to collider.
* Full name: ''particleEmitter.position'' or ''particleEmitter({id}).position''
* Type: 3-component float vector
* Default Value: (0,0,0)
* Example (*.deeclass)
===== orientation =====
Set orientation to attach resource to collider in degrees.
* Full name: ''particleEmitter.orientation'' or ''particleEmitter({id}).orientation''
* Type: 3-component float vector
* Default Value: (0,0,0)
* Example (*.deeclass)
===== bone =====
Set bone to attach resource to. If empty string attach to collider.
* Full name: ''particleEmitter.bone'' or ''particleEmitter({id}).bone''
* Type: string
* Default Value: empty string
* Example (*.deeclass) attach
===== trigger =====
Set trigger casting. If no trigger is set the state of ''casting'' property is used.
* Full name: ''particleEmitter.trigger'' or ''particleEmitter({id}).trigger''
* Type: string
* Default Value: state of ''casting''
* Example (*.deeclass) @openHose & @waterInTank
===== targetCasting =====
Set target casting. Fires target start casting and resets target if stop casting. Target can be used in triggers.
* Full name: ''particleEmitter.targetCasting'' or ''particleEmitter({id}).targetCasting''
* Type: string
* Default Value: empty string
* Example (*.deeclass) hoseSpouting
===== 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.
* Full name: ''particleEmitter.targetLastParticleDied'' or ''particleEmitter({id}).targetLastParticleDied''
* Type: string
* Default Value: empty string
* Example (*.deeclass) hoseSpoutEnd
====== 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.
====== Behavior Tree Actions ======
This behavior adds these behavior tree actions if behavior tree is present. If behavior has non-empty identifier replace ''particleEmitter'' with ''particleEmitter(id)''.
===== particleEmitter.set =====
Set one or more particle emitter parameters.
^Parameter^Value^Description^
|casting|true,false|Enable particle emitter casting|
This is an example of using this action:
true
===== particleEmitter.check =====
Check one or more particle emitter parameters. Action succeeds if all parameter value matches their respective particle emitter parameter otherwise action fails. This action is typically used as first action in a sequence to run the sequence only if a particle emitter parameter matches (or not).
^Parameter^Value^Description^
|casting|true,false|Particle emitter is casting or not|
|wait| |If present action returns BTResult.running instead of BTResult.failed to wait until the checks are all fulfilled|
This is an example of using this action:
true
====== Behavior Tree Conditions ======
This behavior adds these behavior tree conditions if behavior tree is present. If behavior has non-empty identifier replace ''particleEmitter'' with ''particleEmitter(id)''.
===== particleEmitter.check =====
Check one or more particle emitter parameters. Conditions returns true if all parameter value match their respective particle emitter parameter. This condition is typically used to run an action or sequence of actions as long as particle emitter conditions are true.
^Parameter^Value^Description^
|particleEmitter.casting|true,false|Particle emitter is casting or not|
This is an example of using this condition:
true
particleEmitter.check
====== State Machine Actions ======
Same as [[#behavior_tree_actions|Behavior Tree Actions]].
====== State Machine Conditions ======
Same as [[#behavior_tree_conditions|Behavior Tree Conditions]].
====== State Machine Events ======
This behavior sends these state machine events. If behavior has non-empty identifier replace ''particleEmitter'' with ''particleEmitter(id)''.
===== particleEmitter.startCasting =====
Start casting particles.
===== particleEmitter.stopCasting =====
Stop casting particles.
===== particleEmitter.lastParticleDied =====
Last particle of a burst emission died.
====== Required Behaviors ======
This behavior requires no other behaviors.
====== Optional Behaviors ======
* [[behavior_collider|ECBehaviorCollider]]: Attach to collider.
* [[behavior_behaviortree|ECBehaviorBehaviorTree]]: Add actions and conditions for behavior trees to use.
* [[behavior_statemachine|ECBehaviorStateMachine]]: Add actions and conditions for state machine to use and events to send to the state machine.
====== Persistency ======
This behavior does support element class to be persistable (setPersistable). Saves selected color.
====== API Documentation ======
#@LinkApiDocDEDS2_HTML~classDragengine_1_1Scenery_1_1ECBehaviorParticleEmitter.html,ECBehaviorParticleEmitter~@#.
Since DragonScript Module Version ''1.0''
====== Use Cases ======
* Cast particles from an element.
====== 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:
5:0 1 2 6
default
second
other
second
second
water.depemit
====== Live Examples ======
* [[https://github.com/LordOfDragons/deexamples|DEExamples Repository]]