This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| dragengine:modules:dragonscript:behavior_statemachine [2026/10/12 11:59] – ↷ Links adapted because of a move operation dragonlord | dragengine:modules:dragonscript:behavior_statemachine [2026/11/18 16:37] (current) – dragonlord | ||
|---|---|---|---|
| Line 68: | Line 68: | ||
| This behavior adds these state machine actions. | This behavior adds these state machine actions. | ||
| + | |||
| + | ===== self ===== | ||
| + | |||
| + | Set state machine parameters. | ||
| + | |||
| + | ^Parameter^Value^Description^ | ||
| + | |debug.name|string|Set logging name. This name is prepended to logs if enabled.| | ||
| + | |debug.targets|list|List of whitespace separated targets to log. Valid targets: '' | ||
| + | |||
| + | This is an example of using this action to fully hide the owner element: | ||
| + | <code xml> | ||
| + | <action name=' | ||
| + | < | ||
| + | < | ||
| + | </ | ||
| + | </ | ||
| ===== element.set ===== | ===== element.set ===== | ||
| Line 74: | Line 90: | ||
| ^Parameter^Value^Description^ | ^Parameter^Value^Description^ | ||
| - | |visible|true, | + | |visible|'' |
| - | |touchable|true, | + | |touchable|'' |
| This is an example of using this action to fully hide the owner element: | This is an example of using this action to fully hide the owner element: | ||
| Line 84: | Line 100: | ||
| </ | </ | ||
| </ | </ | ||
| - | |||
| ===== element.update ===== | ===== element.update ===== | ||
| Line 92: | Line 107: | ||
| ^Parameter^Value^Description^ | ^Parameter^Value^Description^ | ||
| |dispose| |Dispose of owner element. Make sure this is the last action run in a transition or state. Running actions afterwards can lead to problems.| | |dispose| |Dispose of owner element. Make sure this is the last action run in a transition or state. Running actions afterwards can lead to problems.| | ||
| + | |teleport|'' | ||
| + | * '' | ||
| + | * '' | ||
| + | If element is [[behavior_attachable|attachable]], | ||
| + | |teleport.target|string|Identifier of target| | ||
| |log|string|Print a log message using Element.log() function.| | |log|string|Print a log message using Element.log() function.| | ||
| Line 98: | Line 118: | ||
| <action name=' | <action name=' | ||
| < | < | ||
| + | </ | ||
| + | </ | ||
| + | |||
| + | This is an example of using this action to teleport the element to a spawn point: | ||
| + | <code xml> | ||
| + | <action name=' | ||
| + | < | ||
| + | < | ||
| </ | </ | ||
| </ | </ | ||
| Line 108: | Line 136: | ||
| ^Parameter^Value^Description^ | ^Parameter^Value^Description^ | ||
| + | |interactElement.assign|string|Assign event element to [[behavior_interactelement|ECBehaviorInteractElement]] with identifier matching value string.| | ||
| + | |interact|string|Run interaction with name value on event element.| | ||
| + | |interact.parameters|string|Optional parameters to use with '' | ||
| |runEvent|string|Run named event on all ECBehaviorStateMachine instance of event element with the state machine element as event parameter.| | |runEvent|string|Run named event on all ECBehaviorStateMachine instance of event element with the state machine element as event parameter.| | ||
| Line 123: | Line 154: | ||
| ^Parameter^Value^Description^ | ^Parameter^Value^Description^ | ||
| |action|string|Name of action to run.| | |action|string|Name of action to run.| | ||
| - | |receiveEvents|true, | + | |receiveEvents|'' |
| + | |runEvent|string|Run event on all state machines of element set to receive game world events. The state machine owner is set as event parameter.| | ||
| This is an example of using this action to spawn a new element: | This is an example of using this action to spawn a new element: | ||
| Line 132: | Line 164: | ||
| < | < | ||
| < | < | ||
| + | </ | ||
| + | </ | ||
| + | |||
| + | This is an example of using this action to run event on [[appbehavior_behaviorstatemachine|application state machines]]: | ||
| + | <code xml> | ||
| + | <action name=' | ||
| + | < | ||
| + | < | ||
| </ | </ | ||
| </ | </ | ||
| Line 144: | Line 184: | ||
| ^Parameter^Value^Description^ | ^Parameter^Value^Description^ | ||
| - | |element.visible|true, | + | |element.visible|'' |
| - | |element.touchable|true, | + | |element.touchable|'' |
| - | |element.inGameWorld|true, | + | |element.inGameWorld|'' |
| - | |element.hasParent|true, | + | |element.hasParent|'' |
| This is an example of using this condition to check if the element is visible, touchable, in a game world and not parented to another element: | This is an example of using this condition to check if the element is visible, touchable, in a game world and not parented to another element: | ||
| Line 167: | Line 207: | ||
| ^Parameter^Value^Description^ | ^Parameter^Value^Description^ | ||
| - | |eventElement.flags.set|string|Event element has [[behavior_flags|ECBehaviorBTSMFlags]] with named flag set.| | + | |eventElement.flags.set|string|Event element has [[behavior_flags|ECBehaviorFlags]] with named flag set.| |
| - | |eventElement.flags.clear|string|Event element has [[behavior_flags|ECBehaviorBTSMFlags]] with named flag cleared.| | + | |eventElement.flags.clear|string|Event element has [[behavior_flags|ECBehaviorFlags]] with named flag cleared.| |
| + | |eventElement.interactElement.assigned|string|Event element is assigned to [[behavior_interactelement|ECBehaviorInteractElement]] with identifier matching value string.| | ||
| + | |eventElement.interactElement.assigned.not|string|Event element is not assigned to [[behavior_interactelement|ECBehaviorInteractElement]] with identifier matching value string.| | ||
| This is an example of using this action: | This is an example of using this action: | ||
| Line 264: | Line 306: | ||
| ====== Behavior Tree Actions ====== | ====== Behavior Tree Actions ====== | ||
| - | This behavior adds these behavior tree actions if behavior tree is present. If behavior has non-empty identifier replace '' | + | This behavior adds these behavior tree actions if behavior tree is present. If behavior has non-empty identifier replace '' |
| - | ===== attachSlot.update | + | ===== stateMachine.set ===== |
| - | Update attach slot. | + | Set state machine parameters. |
| ^Parameter^Value^Description^ | ^Parameter^Value^Description^ | ||
| - | |detach|empty string, '' | + | |reset| |Reset state machine |
| - | |interactElement.assign|string|Assign attached element | + | |state|string|Set state machine |
| - | |interact|string|Interact with attachable. If element is absent action fails. Runs interaction with name value. If interaction with name value is absent fails action. If interaction returns false fails action. Otherwise action succeeds.| | + | |
| - | |interact.parameters|string|Optional parameters | + | |
| - | This is an example of using this action: | + | This is an example of using this action |
| <code xml> | <code xml> | ||
| - | <action name='attachSlot.set'> | + | <action name='stateMachine.set'> |
| - | < | + | < |
| </ | </ | ||
| </ | </ | ||
| - | ===== attachSlot.check ===== | + | ===== stateMachine.event ===== |
| - | Check one or more attach slot parameters. Action succeeds if all parameter value matches their respective attach slot parameter otherwise action fails. This action is typically used as first action in a sequence to run the sequence only if a attach slot parameter matches (or not). | + | Run event on state machine. |
| ^Parameter^Value^Description^ | ^Parameter^Value^Description^ | ||
| - | |empty|'' | + | |id|string|Identifier of event to run.| |
| - | |interact.name|string|Name of interaction| | + | |
| - | |interact.has|'' | + | This is an example of using this action to run event '' |
| - | |interact.query|'' | + | <code xml> |
| - | |interact.parameters|string|Optional parameters to use with '' | + | <action name='stateMachine.event'> |
| + | < | ||
| + | </ | ||
| + | </ | ||
| + | |||
| + | ===== stateMachine.check ===== | ||
| + | |||
| + | Check one or more state machine parameters. Action succeeds if all parameter value matches their respective state machine parameter otherwise action fails. This action | ||
| + | |||
| + | ^Parameter^Value^Description^ | ||
| + | |state|string|Current state machine state identifier matches value.| | ||
| + | |state.not|string|Current state machine state identifier does not match value.| | ||
| + | |state.starts|string|Current state machine state identifier begins | ||
| + | |state.starts.not|string|Current state machine state identifier does not begin with value.| | ||
| + | |state.ends|string|Current state machine state identifier ends with value.| | ||
| + | |state.ends.not|string|Current state machine state identifier does not end with value.| | ||
| + | |state.contains|string|Current state machine state identifier contains value.| | ||
| + | |state.contains.not|string|Current state machine state identifier does not contain value.| | ||
| |wait| |If present action returns BTResult.running instead of BTResult.failed to wait until the checks are all fulfilled| | |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: | + | This is an example of using this action |
| <code xml> | <code xml> | ||
| < | < | ||
| - | <action name='attachSlot.check'> | + | <action name='stateMachine.check'> |
| - | < | + | < |
| </ | </ | ||
| - | <!-- actions here run only if attach slot is not empty, hence an attachable is present | + | <!-- actions here run only if state machine |
| </ | </ | ||
| </ | </ | ||
| Line 307: | Line 364: | ||
| ====== Behavior Tree Conditions ====== | ====== Behavior Tree Conditions ====== | ||
| - | This behavior adds these behavior tree conditions if behavior tree is present. If behavior has non-empty identifier replace '' | + | This behavior adds these behavior tree conditions if behavior tree is present. If behavior has non-empty identifier replace '' |
| - | ===== attachSlot.check ===== | + | ===== stateMachine.check ===== |
| - | Check one or more attach slot parameters. Conditions returns true if all parameter value match their respective | + | Check one or more state machine |
| ^Parameter^Value^Description^ | ^Parameter^Value^Description^ | ||
| - | |attachSlot.empty|'' | + | |stateMachine.state|string|Current state machine state identifier matches value.| |
| - | |attachSlot.interact.name|string|Name of interaction| | + | |stateMachine.state.not|string|Current state machine state identifier does not match value.| |
| - | |attachSlot.interact.has|'' | + | |stateMachine.state.starts|string|Current state machine state identifier begins |
| - | |attachSlot.interact.query|'' | + | |stateMachine.state.starts.not|string|Current state machine state identifier does not begin with value.| |
| - | |attachSlot.interact.parameters|string|Optional parameters to use with '' | + | |stateMachine.state.ends|string|Current state machine state identifier ends with value.| |
| + | |stateMachine.state.ends.not|string|Current state machine state identifier does not end with value.| | ||
| + | |stateMachine.state.contains|string|Current state machine state identifier contains value.| | ||
| + | |stateMachine.state.contains.not|string|Current state machine state identifier does not contain value.| | ||
| - | This is an example of using this condition: | + | This is an example of using this condition |
| <code xml> | <code xml> | ||
| <action name=' | <action name=' | ||
| - | <parameter name=' | + | <condition>stateMachine.check</condition> |
| - | <condition> | + | <parameter name=' |
| </ | </ | ||
| </ | </ | ||