This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| dragengine:modules:dragonscript:behavior_lookedat [2024/03/14 16:55] – dragonlord | dragengine:modules:dragonscript:behavior_lookedat [2025/05/04 13:47] (current) – [lookedAt.check] dragonlord | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| {{tag> | {{tag> | ||
| <WRAP youarehere> | <WRAP youarehere> | ||
| - | [[: | + | [[: |
| </ | </ | ||
| Line 19: | Line 19: | ||
| ====== Element Class Properties ====== | ====== Element Class Properties ====== | ||
| - | Element class properties have the prefix **lookedAt.**. | ||
| - | This behavior defines no element | + | Element |
| - | ====== | + | ====== |
| - | This behavior does not required other behaviors to be present. | + | |
| - | + | ||
| - | ====== Optional Behaviors ====== | + | |
| - | This behavior does not support optional behaviors. | + | |
| - | + | ||
| - | ====== Persistency ====== | + | |
| - | This behavior does support element class to be persistable (setPersistable). Saves the list of actors looking at the element. | + | |
| - | ====== Events ====== | ||
| This behavior supports adding listeners. These events can be received: | This behavior supports adding listeners. These events can be received: | ||
| ===== actorStartsLookingAt ===== | ===== actorStartsLookingAt ===== | ||
| - | Actors starts | + | |
| + | Actors starts looking at object. | ||
| ===== actorStopsLookingAt ===== | ===== actorStopsLookingAt ===== | ||
| - | Actors stops looking at object. Event contains // | ||
| + | Actors stops looking at object. | ||
| + | |||
| + | ====== Behavior Tree Actions ====== | ||
| + | |||
| + | This behavior adds these behavior tree actions if behavior tree is present. | ||
| + | |||
| + | ===== 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|'' | ||
| + | |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> | ||
| + | < | ||
| + | <action name=' | ||
| + | < | ||
| + | </ | ||
| + | <!-- actions here run only if element is looked at by player --> | ||
| + | </ | ||
| + | </ | ||
| + | |||
| + | ====== 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|'' | ||
| + | |||
| + | This is an example of using this condition: | ||
| + | <code xml> | ||
| + | <action name=' | ||
| + | < | ||
| + | < | ||
| + | </ | ||
| + | </ | ||
| + | |||
| + | ====== State Machine Actions ====== | ||
| + | |||
| + | Same as [[# | ||
| + | |||
| + | ====== State Machine Conditions ====== | ||
| + | |||
| + | Same as [[# | ||
| + | |||
| + | ====== State Machine Events ====== | ||
| + | |||
| + | This behavior sends these state machine events. | ||
| + | |||
| + | ===== lookedAt.start ===== | ||
| + | |||
| + | Actors starts looking at object. | ||
| + | |||
| + | ===== lookedAt.stop ===== | ||
| + | |||
| + | Actors stops looking at object. | ||
| + | |||
| + | ====== Required Behaviors ====== | ||
| + | |||
| + | This behavior does not required other behaviors to be present. | ||
| + | |||
| + | ====== Optional Behaviors ====== | ||
| + | |||
| + | * [[behavior_behaviortree|ECBehaviorBehaviorTree]]: | ||
| + | * [[behavior_statemachine|ECBehaviorStateMachine]]: | ||
| + | |||
| + | ====== Persistency ====== | ||
| + | |||
| + | This behavior does support element class to be persistable (setPersistable). | ||
| ====== API Documentation ====== | ====== API Documentation ====== | ||
| + | |||
| # | # | ||
| - | Since DragonScript Module Version | + | Since DragonScript Module Version |
| ====== Use Cases ====== | ====== Use Cases ====== | ||
| + | |||
| * Show outline and interact prompts if player looks at object. | * Show outline and interact prompts if player looks at object. | ||
| * For NPCs to react to player (or other actors) looking at them (for example looking back at player). | * For NPCs to react to player (or other actors) looking at them (for example looking back at player). | ||
| Line 66: | Line 142: | ||
| end | end | ||
| </ | </ | ||
| + | |||
| + | ====== Behavior Factory ====== | ||
| + | |||
| + | Using element class supporting adding behaviors the behavior can be added like this: | ||
| + | <code xml> | ||
| + | <?xml version=' | ||
| + | < | ||
| + | < | ||
| + | <!-- optional: use behavior tree with id instead of empty string --> | ||
| + | <string name=' | ||
| + | | ||
| + | <!-- optional: use state machine with id instead of empty string --> | ||
| + | <string name=' | ||
| + | | ||
| + | <!-- set element properties. omit property prefix if used inside behavior tag --> | ||
| + | <string name=' | ||
| + | </ | ||
| + | </ | ||
| + | </ | ||
| + | |||
| + | ====== Live Examples ====== | ||
| + | |||
| + | * [[https:// | ||
| + | |||