This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revision | |||
dragengine:modules:dragonscript:behavior_lookedat [2024/03/14 16:55] – dragonlord | dragengine:modules:dragonscript:behavior_lookedat [2025/03/12 21:26] (current) – dragonlord | ||
---|---|---|---|
Line 19: | Line 19: | ||
====== Element Class Properties ====== | ====== Element Class Properties ====== | ||
- | Element class properties have the prefix **lookedAt.**. | ||
- | This behavior defines no element | + | Element |
====== Required Behaviors ====== | ====== Required Behaviors ====== | ||
+ | |||
This behavior does not required other behaviors to be present. | This behavior does not required other behaviors to be present. | ||
====== Optional Behaviors ====== | ====== Optional Behaviors ====== | ||
+ | |||
This behavior does not support optional behaviors. | This behavior does not support optional behaviors. | ||
====== Persistency ====== | ====== Persistency ====== | ||
- | This behavior does support element class to be persistable (setPersistable). Saves the list of actors looking at the element. | + | |
+ | This behavior does support element class to be persistable (setPersistable). | ||
====== Events ====== | ====== 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. | ||
====== 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 72: | ||
end | end | ||
</ | </ | ||
+ | |||
+ | ====== Behavior Factory ====== | ||
+ | |||
+ | Using element class supporting adding behaviors the behavior can be added like this: | ||
+ | <code xml> | ||
+ | <?xml version=' | ||
+ | < | ||
+ | < | ||
+ | <!-- set element properties. omit property prefix if used inside behavior tag --> | ||
+ | <string name=' | ||
+ | </ | ||
+ | </ | ||
+ | </ | ||
+ | |||
+ | ====== Live Examples ====== | ||
+ | |||
+ | * [[https:// | ||
+ |