User Tools

Site Tools


dragengine:modules:dragonscript:behavior_lookedat

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_lookedat [2025/03/12 21:26] dragonlorddragengine:modules:dragonscript:behavior_lookedat [2025/05/04 13:47] (current) – [lookedAt.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]] >> **ECBehaviorLookedAt**+[[: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]] >> **ECBehaviorLookedAt**
 </WRAP> </WRAP>
  
Line 22: Line 22:
 Element class properties have the prefix ''lookedAt.''. Element class properties have the prefix ''lookedAt.''.
  
-====== Required Behaviors ======+====== Events ======
  
-This behavior does not required other behaviors to be present.+This behavior supports adding listenersThese events can be received:
  
-====== Optional Behaviors ======+===== actorStartsLookingAt =====
  
-This behavior does not support optional behaviors.+Actors starts looking at object.
  
-====== Persistency ======+===== actorStopsLookingAt =====
  
-This behavior does support element class to be persistable (setPersistable).+Actors stops looking at object.
  
-====== Events ======+====== Behavior Tree Actions ======
  
-This behavior supports adding listenersThese events can be received:+This behavior adds these behavior tree actions if behavior tree is present.
  
-===== actorStartsLookingAt =====+===== lookedAt.check ===== 
 + 
 +Check one or more looked-at parameters. Action succeeds if all parameter value matches their respective looked-at parameter otherwise action fails. This action is typically used as first action in a sequence to run the sequence only if a looked-at parameter matches (or not). 
 + 
 +^Parameter^Value^Description^ 
 +|count|integer|Count of actors looking at element equals integer value| 
 +|count.not|integer|Count of actors looking at element does not equal integer value| 
 +|count.less|integer|Count of actors looking at element is less than integer value| 
 +|count.greater|integer|Count of actors looking at element is greater than integer value| 
 +|player|''true'', ''false''|Player is looking at element| 
 +|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='lookedAt.check'> 
 +    <parameter name='player'>true</parameter> 
 +  </action> 
 +  <!-- actions here run only if element is looked at by player --> 
 +</sequence> 
 +</code> 
 + 
 +====== Behavior Tree Conditions ====== 
 + 
 +This behavior adds these behavior tree conditions if behavior tree is present. 
 + 
 +===== lookedAt.check ===== 
 + 
 +Check one or more looked-at parameters. Conditions returns true if all parameter value match their respective looked-at parameter. This condition is typically used to run an action or sequence of actions as long as looked-at conditions are true. 
 + 
 +^Parameter^Value^Description^ 
 +|lookedAt.count|integer|Count of actors looking at element equals integer value| 
 +|lookedAt.count.not|integer|Count of actors looking at element does not equal integer value| 
 +|lookedAt.count.less|integer|Count of actors looking at element is less than integer value| 
 +|lookedAt.count.greater|integer|Count of actors looking at element is greater than integer value| 
 +|lookedAt.player|''true'', ''false''|Player is looking at element| 
 + 
 +This is an example of using this condition: 
 +<code xml> 
 +<action name='myAction' id='doing something'> 
 +  <parameter name='lookedAt.player'>true</parameter> 
 +  <condition>lookedAt.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. 
 + 
 +===== lookedAt.start =====
  
 Actors starts looking at object. Actors starts looking at object.
  
-===== actorStopsLookingAt =====+===== lookedAt.stop =====
  
 Actors stops looking at object. Actors stops looking at object.
 +
 +====== Required Behaviors ======
 +
 +This behavior does not required other behaviors to be present.
 +
 +====== 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 ======
 +
 +This behavior does support element class to be persistable (setPersistable).
  
 ====== API Documentation ====== ====== API Documentation ======
Line 80: Line 150:
 <elementClass name='MyClass' class='GenericBehaviorElement'> <elementClass name='MyClass' class='GenericBehaviorElement'>
   <behavior type='ECBehaviorLookedAt'>   <behavior type='ECBehaviorLookedAt'>
 +    <!-- 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 -->
     <string name='.name'>value</string>     <string name='.name'>value</string>
dragengine/modules/dragonscript/behavior_lookedat.1741814785.txt.gz · Last modified: 2025/03/12 21:26 by dragonlord