User Tools

Site Tools


dragengine:modules:dragonscript:behavior_touchsensor

Differences

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

Link to this comparison view

Next revision
Previous revision
dragengine:modules:dragonscript:behavior_touchsensor [2025/03/13 16:48] – created dragonlorddragengine:modules:dragonscript:behavior_touchsensor [2025/05/04 13:50] (current) – [touchSensor.check] dragonlord
Line 1: Line 1:
 {{tag>dragonscript behavior}} {{tag>dragonscript behavior}}
 <WRAP youarehere> <WRAP youarehere>
-[[:start|Start Page]] >> [[main|DragonScript Scripting Language]] >> [[abstractions#behavior_elementsquick_and_easy_development|Behavior Elements: Quick and Easy Development]] >> **ECBehaviorTouchSensor**+[[: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]] >> **ECBehaviorTouchSensor**
 </WRAP> </WRAP>
  
Line 90: Line 90:
  
 Element entered touch sensor. Element entered touch sensor.
- 
  
 ===== elementLeft ===== ===== elementLeft =====
Line 99: Line 98:
  
 Element can touch this touch sensor if all listeners return true. Element can touch this touch sensor if all listeners return true.
 +
 +====== Behavior Tree Actions ======
 +
 +This behavior adds these behavior tree actions if behavior tree is present. If behavior has non-empty identifier replace ''touchSensor'' with ''touchSensor(id)''.
 +
 +===== touchSensor.set =====
 +
 +Set one or more touch sensor parameters.
 +
 +^Parameter^Value^Description^
 +|enabled|''true'', ''false''|Enable touch sensor|
 +
 +This is an example of using this action:
 +<code xml>
 +<action name='touchSensor.set'>
 +  <parameter name='enabled'>true</parameter>
 +</action>
 +</code>
 +
 +===== touchSensor.check =====
 +
 +Check one or more touch sensor parameters. Action succeeds if all parameter value matches their respective touch sensor parameter otherwise action fails. This action is typically used as first action in a sequence to run the sequence only if a touch sensor parameter matches (or not).
 +
 +^Parameter^Value^Description^
 +|count|integer|Count of touching elements equals integer value|
 +|count.not|integer|Count of touching elements does not equal integer value|
 +|count.less|integer|Count of touching elements is less than integer value|
 +|count.greater|integer|Count of touching elements is greater than integer value|
 +|player|''true'', ''false''|Player is touching touch sensor|
 +|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='touchSensor.check'>
 +    <parameter name='player'>true</parameter>
 +  </action>
 +  <!-- actions here run only if player is touching touch sensor -->
 +</sequence>
 +</code>
 +
 +====== Behavior Tree Conditions ======
 +
 +This behavior adds these behavior tree conditions if behavior tree is present.
 +
 +===== touchSensor.check =====
 +
 +Check one or more touch sensor parameters. Conditions returns true if all parameter value match their respective touch sensor parameter. This condition is typically used to run an action or sequence of actions as long as touch sensor conditions are true.
 +
 +^Parameter^Value^Description^
 +|touchSensor.count|integer|Count of touching elements equals integer value|
 +|touchSensor.count.not|integer|Count of touching elements does not equal integer value|
 +|touchSensor.count.less|integer|Count of touching elements is less than integer value|
 +|touchSensor.count.greater|integer|Count of touching elements is greater than integer value|
 +|touchSensor.player|''true'', ''false''|Player is touching touch sensor|
 +
 +This is an example of using this condition:
 +<code xml>
 +<action name='myAction' id='doing something'>
 +  <parameter name='touchSensor.player'>true</parameter>
 +  <condition>touchSensor.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. If behavior has non-empty identifier replace ''touchSensor'' with ''touchSensor(id)''.
 +
 +===== touchSensor.entered =====
 +
 +Element entered touch sensor.
 +
 +===== touchSensor.left =====
 +
 +Element left touch sensor.
  
 ====== Required Behaviors ====== ====== Required Behaviors ======
Line 107: Line 189:
  
   * [[behavior_collider|ECBehaviorCollider]]: Attach to collider.   * [[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 ====== ====== Persistency ======
Line 149: Line 233:
      
   <behavior type='ECBehaviorTouchSensor'>   <behavior type='ECBehaviorTouchSensor'>
 +    <!-- optional: set collision filter. default value '4:3' which means
 +                   category BaseGameApp.CollisionFilterBit.trigger
 +                   filter BaseGameApp.CollisionFilterBit.actorAI.
 +                   format is '', 'category' or 'category:filter' where category and filter
 +                   are a list of bits to set. -->
 +    <string name='collisionFilter'>3:4 0</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>
 +    
     <!-- set element properties. omit property prefix if used inside behavior tag -->     <!-- set element properties. omit property prefix if used inside behavior tag -->
     <boolean name='.shapeFromSize'>true</boolean>     <boolean name='.shapeFromSize'>true</boolean>
dragengine/modules/dragonscript/behavior_touchsensor.1741884485.txt.gz · Last modified: 2025/03/13 16:48 by dragonlord