This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
dragengine:modules:dragonscript:behavior_clearpath [2024/03/14 16:54] – dragonlord | dragengine:modules:dragonscript:behavior_clearpath [2025/05/05 13:25] (current) – dragonlord | ||
---|---|---|---|
Line 1: | Line 1: | ||
{{tag> | {{tag> | ||
<WRAP youarehere> | <WRAP youarehere> | ||
- | [[: | + | [[: |
</ | </ | ||
Line 8: | Line 8: | ||
====== ECBehaviorClearPath ====== | ====== ECBehaviorClearPath ====== | ||
+ | |||
+ | <WRAP center 100%> | ||
+ | <WRAP center box 450px> | ||
+ | {{youtube> | ||
+ | <WRAP centeralign> | ||
+ | </ | ||
+ | </ | ||
Behavior adding support to actors to make other actors get out of the way. | Behavior adding support to actors to make other actors get out of the way. | ||
Line 19: | Line 26: | ||
To use this behavior add it to the element class and make sure to call setShapeSphere() to set up the collision test shapes. The best time to do this is either in BehaviorElement.init() or inside BaseActorAction if you need to change them per action. | To use this behavior add it to the element class and make sure to call setShapeSphere() to set up the collision test shapes. The best time to do this is either in BehaviorElement.init() or inside BaseActorAction if you need to change them per action. | ||
- | **Configurations** | + | //Configurations// |
There are usually two possible configurations used for this behavior. | There are usually two possible configurations used for this behavior. | ||
Line 29: | Line 36: | ||
For most situations the first configuration is the one to choose since it prevents the actor-actor stuck problems while exhibiting the least side effects. The second configuration though can be insteresting to switch to if actors need a clear path for example while running away. For this reason the first configuration is used as default. | For most situations the first configuration is the one to choose since it prevents the actor-actor stuck problems while exhibiting the least side effects. The second configuration though can be insteresting to switch to if actors need a clear path for example while running away. For this reason the first configuration is used as default. | ||
- | <WRAP center 100%> | ||
- | <WRAP center box 450px> | ||
- | {{youtube> | ||
- | <WRAP centeralign> | ||
- | </ | ||
- | </ | ||
====== Instance Counts ====== | ====== Instance Counts ====== | ||
This behavior can be used only once on an element. The behavior always has identifier empty string. | This behavior can be used only once on an element. The behavior always has identifier empty string. | ||
====== Element Class Properties ====== | ====== Element Class Properties ====== | ||
- | Element class properties have the prefix | + | Element class properties have the prefix |
===== enabled ===== | ===== enabled ===== | ||
Determines if the behavior is initially enabled. | Determines if the behavior is initially enabled. | ||
- | * Full name: "clearPath.enabled" | + | * Full name: '' |
* Type: boolean | * Type: boolean | ||
- | * Default Value: true | + | * Default Value: |
* Example (*.deeclass) <code xml>< | * Example (*.deeclass) <code xml>< | ||
===== checkInterval ===== | ===== checkInterval ===== | ||
Check interval in seconds. | Check interval in seconds. | ||
- | * Full name: "clearPath.checkInterval" | + | * Full name: '' |
* Type: floating point | * Type: floating point | ||
- | * Minimum Value: 0 | ||
* Default value: 1 | * Default value: 1 | ||
+ | * Restriction: | ||
* Example (*.deeclass) <code xml>< | * Example (*.deeclass) <code xml>< | ||
Line 60: | Line 61: | ||
* Full name: " | * Full name: " | ||
* Type: floating point | * Type: floating point | ||
- | * Minimum Value: 0 | ||
* Default value: 0.05 | * Default value: 0.05 | ||
+ | * Restriction: | ||
* Example (*.deeclass) <code xml>< | * Example (*.deeclass) <code xml>< | ||
+ | |||
+ | ====== Behavior Tree Actions ====== | ||
+ | |||
+ | This behavior adds these behavior tree actions if behavior tree is present. | ||
+ | |||
+ | ===== clearPath.set ===== | ||
+ | |||
+ | Set one or more clear path parameters. | ||
+ | |||
+ | ^Parameter^Value^Description^ | ||
+ | |enabled|'' | ||
+ | |check.interval|float|Check interval in seconds| | ||
+ | |check.timer|float|Check timer in seconds. Typically 0 to reset timer| | ||
+ | |clearPath.time|float|Clear path time in seconds indicating how far ahead the actors clear path| | ||
+ | |||
+ | This is an example of using this action: | ||
+ | <code xml> | ||
+ | <action name=' | ||
+ | < | ||
+ | </ | ||
+ | </ | ||
+ | |||
+ | ===== clearPath.check ===== | ||
+ | |||
+ | Check one or more clear path parameters. Action succeeds if all parameter value matches their respective clear path parameter otherwise action fails. This action is typically used as first action in a sequence to run the sequence only if a clear path parameter matches (or not). | ||
+ | |||
+ | ^Parameter^Value^Description^ | ||
+ | |enabled|'' | ||
+ | |check.interval.less|float|Check interval is less then value seconds| | ||
+ | |check.interval.greater|float|Check interval is greater then value seconds| | ||
+ | |check.timer.less|float|Check timer is less then value seconds| | ||
+ | |check.timer.greater|float|Check timer is greater then value seconds| | ||
+ | |clearPath.time.less|float|Clear path time is less then value seconds| | ||
+ | |clearPath.time.greater|float|Clear path time is greater then value seconds| | ||
+ | |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 clear path is enabled --> | ||
+ | </ | ||
+ | </ | ||
+ | |||
+ | ====== Behavior Tree Conditions ====== | ||
+ | |||
+ | This behavior adds these behavior tree conditions if behavior tree is present. | ||
+ | |||
+ | ===== clearPath.check ===== | ||
+ | |||
+ | Check one or more clear path parameters. Conditions returns true if all parameter value match their respective clear path parameter. This condition is typically used to run an action or sequence of actions as long as clear path conditions are true. | ||
+ | |||
+ | ^Parameter^Value^Description^ | ||
+ | |clearPath.enabled|'' | ||
+ | |clearPath.check.interval.less|float|Check interval is less then value seconds| | ||
+ | |clearPath.check.interval.greater|float|Check interval is greater then value seconds| | ||
+ | |clearPath.check.timer.less|float|Check timer is less then value seconds| | ||
+ | |clearPath.check.timer.greater|float|Check timer is greater then value seconds| | ||
+ | |clearPath.clearPath.time.less|float|Clear path time is less then value seconds| | ||
+ | |clearPath.clearPath.time.greater|float|Clear path time is greater then value seconds| | ||
+ | |||
+ | 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 no state machine events. | ||
====== Required Behaviors ====== | ====== Required Behaviors ====== | ||
Line 68: | Line 151: | ||
====== Optional Behaviors ====== | ====== Optional Behaviors ====== | ||
- | This behavior | + | |
+ | * [[behavior_behaviortree|ECBehaviorBehaviorTree]]: | ||
+ | * [[behavior_statemachine|ECBehaviorStateMachine]]: | ||
====== Persistency ====== | ====== Persistency ====== | ||
- | This behavior does support element class to be persistable (setPersistable). Saves enabled, check interval, clear path time and the elapsed check interval time. | + | 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 ====== | ||
Line 94: | Line 179: | ||
| | ||
- | // create required behaviors | ||
| | ||
| | ||
| | ||
| | ||
- | |||
- | // create clear path behavior. the default settings cause the element | ||
- | // to clear path up to a few centimeters ahead. | ||
| | ||
end | end | ||
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 --> | ||
+ | <float name=' | ||
+ | </ | ||
+ | </ | ||
+ | </ | ||
+ | |||
+ | ====== Live Examples ====== | ||
+ | |||
+ | * [[https:// | ||
+ |