User Tools

Site Tools


dragengine:modules:dragonscript:behavior_triggered

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
dragengine:modules:dragonscript:behavior_triggered [2025/03/13 17:17] dragonlorddragengine:modules:dragonscript:behavior_triggered [2025/05/04 13:50] (current) – [trigger.check] dragonlord
Line 16: Line 16:
  
 The initial state of the element is ''false''. If the element is added to the game world notifyListeners() is only called if the trigger expression is ''true'' at this time. The initial state of the element is ''false''. If the element is added to the game world notifyListeners() is only called if the trigger expression is ''true'' at this time.
 +
 +Optionally a synchronized trigger can be specified. If set users of this trigger should use the synchronized trigger instead of this trigger. This allows setting a single trigger expression in an element stub to affect multiple triggers in the same element class.
  
 ====== Instance Counts ====== ====== Instance Counts ======
Line 32: Line 34:
  
 ===== triggerExpressionFalse ===== ===== triggerExpressionFalse =====
 +
 +Trigger expression changed to false.
 +
 +====== Behavior Tree Actions ======
 +
 +This behavior adds these behavior tree actions if behavior tree is present. Replace ''trigger'' by the value of ''propertyName'' if used.
 +
 +===== trigger.check =====
 +
 +Check one or more triggered trigger parameters. Action succeeds if all parameter value matches their respective triggered trigger parameter otherwise action fails. This action is typically used as first action in a sequence to run the sequence only if a triggered trigger parameter matches (or not).
 +
 +^Parameter^Value^Description^
 +|state|''true'', ''false''|Trigger expression evaluates to true or false|
 +|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:
 +<code xml>
 +<sequence>
 +  <action name='triggered.check'>
 +    <parameter name='state'>true</parameter>
 +  </action>
 +  <!-- actions here run only if trigger expression evaluates to true -->
 +</sequence>
 +</code>
 +
 +====== Behavior Tree Conditions ======
 +
 +This behavior adds these behavior tree conditions if behavior tree is present. Replace ''trigger'' by the value of ''propertyName'' if used.
 +
 +===== trigger.check =====
 +
 +Check one or more triggered trigger parameters. Conditions returns true if all parameter value match their respective triggered trigger parameter. This condition is typically used to run an action or sequence of actions as long as triggered trigger conditions are true.
 +
 +^Parameter^Value^Description^
 +|triggered.state|''true'', ''false''|Trigger expression triggereds to true or false|
 +
 +This is an example of using this condition:
 +<code xml>
 +<action name='myAction' id='doing something'>
 +  <parameter name='triggered.state'>true</parameter>
 +  <condition>triggered.check</condition>
 +</action>
 +</code>
 +
 +====== 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. Replace ''trigger'' by the value of ''propertyName'' if used.
 +
 +===== trigger.true =====
 +
 +Trigger expression changed to true.
 +
 +===== trigger.false =====
  
 Trigger expression changed to false. Trigger expression changed to false.
Line 41: Line 104:
 ====== Optional Behaviors ====== ====== Optional Behaviors ======
  
-This behavior does not support optional behaviors.+  * [[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 ====== ====== Persistency ======
Line 84: Line 148:
                    depending if id is empty string or not. -->                    depending if id is empty string or not. -->
     <string name='propertyName'>trigger</string>     <string name='propertyName'>trigger</string>
 +    
 +    <!-- optional: identifier of ECBehaviorTriggered to synchronize with or empty
 +                   string to not synchronize. default is empty string. -->
 +    <string name='synchronize'>other</string>
 +    
 +    <!-- optional: use behavior tree with id instead of empty string -->
 +    <string name='behaviorTree'>second</string>
 +    
 +    <!-- optional: use state machine with id instead of empty string -->
 +    <string name='stateMachine'>second</string>
   </behavior>   </behavior>
      
dragengine/modules/dragonscript/behavior_triggered.1741886240.txt.gz · Last modified: 2025/03/13 17:17 by dragonlord