This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
dragengine:modules:dragonscript:behavior_avoidcollision [2025/03/12 01:56] – created dragonlord | dragengine:modules:dragonscript:behavior_avoidcollision [2025/05/04 23:16] (current) – dragonlord | ||
---|---|---|---|
Line 1: | Line 1: | ||
{{tag> | {{tag> | ||
<WRAP youarehere> | <WRAP youarehere> | ||
- | [[: | + | [[: |
</ | </ | ||
Line 15: | Line 15: | ||
To use this behavior add it to the element class and make sure to call setShapesSphere() 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 setShapesSphere() 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. | ||
+ | See also: | ||
+ | * [[gamedev: | ||
====== Instance Counts ====== | ====== Instance Counts ====== | ||
This behavior can be used only once on an element. | This behavior can be used only once on an element. | ||
Line 30: | Line 32: | ||
====== Events ====== | ====== Events ====== | ||
+ | |||
This behavior has no events. | This behavior has no events. | ||
+ | |||
+ | ====== Behavior Tree Actions ====== | ||
+ | |||
+ | This behavior adds these behavior tree actions if behavior tree is present. | ||
+ | |||
+ | ===== avoidCollision.set ===== | ||
+ | |||
+ | Set one or more force field parameters. | ||
+ | |||
+ | ^Parameter^Value^Description^ | ||
+ | |waitBehindObstacles|'' | ||
+ | |enabled|'' | ||
+ | |||
+ | This is an example of using this action: | ||
+ | <code xml> | ||
+ | <action name=' | ||
+ | < | ||
+ | </ | ||
+ | </ | ||
+ | |||
+ | ===== avoidCollision.stop ===== | ||
+ | |||
+ | Stop avoiding collision. | ||
+ | |||
+ | This is an example of using this action: | ||
+ | <code xml> | ||
+ | <action name=' | ||
+ | </ | ||
+ | |||
+ | ===== avoidCollision.check ===== | ||
+ | |||
+ | Check one or more force field parameters. Action succeeds if all parameter value matches their respective force field parameter otherwise action fails. This action is typically used as first action in a sequence to run the sequence only if a force field parameter matches (or not). | ||
+ | |||
+ | ^Parameter^Value^Description^ | ||
+ | |waitBehindObstacles|'' | ||
+ | |enabled|'' | ||
+ | |avoiding|'' | ||
+ | |avoiding.time.less|float|Ramining time avoiding collision is less than value seconds| | ||
+ | |avoiding.time.greater|float|Ramining time avoiding collision is greater than 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 actor is avoiding a collision --> | ||
+ | </ | ||
+ | </ | ||
+ | |||
+ | ====== Behavior Tree Conditions ====== | ||
+ | |||
+ | This behavior adds these behavior tree conditions if behavior tree is present. If behavior has non-empty identifier replace '' | ||
+ | |||
+ | ===== avoidCollision.check ===== | ||
+ | |||
+ | Check one or more force field parameters. Conditions returns true if all parameter value match their respective force field parameter. This condition is typically used to run an action or sequence of actions as long as force field conditions are true. | ||
+ | |||
+ | ^Parameter^Value^Description^ | ||
+ | |avoidCollision.waitBehindObstacles|'' | ||
+ | |avoidCollision.enabled|'' | ||
+ | |avoidCollision.avoiding|'' | ||
+ | |avoidCollision.avoiding.time.less|float|Ramining time avoiding collision is less than value seconds| | ||
+ | |avoidCollision.avoiding.time.greater|float|Ramining time avoiding collision is greater than 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 these state machine events. | ||
+ | |||
+ | ===== avoidCollision.avoid ===== | ||
+ | |||
+ | Avoid collision. | ||
+ | |||
+ | ===== avoidCollision.stop ===== | ||
+ | |||
+ | Stop avoiding collision. | ||
====== Required Behaviors ====== | ====== Required Behaviors ====== | ||
- | This behavior requires these other behaviors: | ||
* [[behavior_actormover|ECBehaviorActorMover]] | * [[behavior_actormover|ECBehaviorActorMover]] | ||
====== Optional Behaviors ====== | ====== Optional Behaviors ====== | ||
- | This behavior does support these optional behaviors: | ||
* [[behavior_rideon|ECBehaviorRideOn]]: | * [[behavior_rideon|ECBehaviorRideOn]]: | ||
+ | * [[behavior_behaviortree|ECBehaviorBehaviorTree]]: | ||
+ | * [[behavior_statemachine|ECBehaviorStateMachine]]: | ||
====== Persistency ====== | ====== Persistency ====== | ||
Line 109: | Line 205: | ||
are a list of bits to set. --> | are a list of bits to set. --> | ||
<string name=' | <string name=' | ||
+ | | ||
+ | <!-- 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 --> | <!-- set element properties. omit property prefix if used inside behavior tag --> |