Start Page » DragonScript Scripting Language » Abstraction Layers: How you want to build your Game » Behavior Elements » ECBehaviorAlignActor
Behavior adding support to actors to align to a specific position and orientation.
Manipulates ECBehaviorLocomotion to move an actor a short distance to a specific position, orientation and looking direction. This is typically required for actors intending to interact with objects. In this case the animation of the actor has to match the object it is interacting with. Actor actions will use this behavior to achieve this goal.
This behavior can be used only once on an element.
Element class properties have the prefix alignActor.
.
Set movement speed while aligning in meters per seconds.
alignActor.speed
<float name='alignActor.speed'>2</float>
This behavior has these events:
Actor starts aligning.
Actor finished aligning.
This behavior adds these behavior tree actions if behavior tree is present.
Update align actor.
Parameter | Value | Description |
---|---|---|
clear | Clear target | |
initLocomotionPlayer | Init locomotion for player actor use | |
cancel | Cancel aligning if running |
This is an example of using this action:
<action name='alignActor.set'> <parameter name='enabled'>true</parameter> </action>
Check one or more align actor parameters. Action succeeds if all parameter value matches their respective align actor parameter otherwise action fails. This action is typically used as first action in a sequence to run the sequence only if a align actor parameter matches (or not).
Parameter | Value | Description |
---|---|---|
arrived | true , false | Actor arrived at target but might still be turning |
finished | true , false | Actor arrived at target and finished turning |
succeeded | true , false | Actor could arrive at target and turn to the desired orientation |
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:
<sequence> <action name='alignActor.check'> <parameter name='finished'>true</parameter> </action> <!-- actions here run only if align actor finished --> </sequence>
This behavior adds these behavior tree conditions if behavior tree is present.
Check one or more align actor parameters. Conditions returns true if all parameter value match their respective align actor parameter. This condition is typically used to run an action or sequence of actions as long as align actor conditions are true.
Parameter | Value | Description |
---|---|---|
alignActor.arrived | true , false | Actor arrived at target but might still be turning |
alignActor.finished | true , false | Actor arrived at target and finished turning |
alignActor.succeeded | true , false | Actor could arrive at target and turn to the desired orientation |
This is an example of using this condition:
<action name='myAction' id='doing something'> <parameter name='alignActor.finished'>true</parameter> <condition>alignActor.check</condition> </action>
Same as Behavior Tree Actions.
Same as Behavior Tree Conditions.
This behavior sends these state machine events.
Actor begins aligning.
Actor finished aligning.
This behavior does support element class to be persistable (setPersistable).
Since DragonScript Module Version 1.0
This example defines an element which supports aligning actor.
class MyElement extends BehaviorElementClass public var ECBehaviorComponent component public var ECBehaviorCollider collider public var ECBehaviorColliderAI colliderAI public var ECBehaviorLocomotion locomotion public var ECBehaviorConversationActor conversationActor public var ECBehaviorAlignActor alignActor func new() component = ECBehaviorComponent.new(this, null) collider = ECBehaviorCollider.new(this, component) colliderAI = ECBehaviorColliderAI.new(this, collider) locomotion = ECBehaviorLocomotion.new(this, colliderAI) conversationActor = ECBehaviorConversationActor.new(this) alignActor = ECBehaviorAlignActor.new(this, locomotion, conversationActor) end end
Using element class supporting adding behaviors the behavior can be added like this:
<?xml version='1.0' encoding='UTF-8'?> <elementClass name='MyClass' class='GenericBehaviorElement'> <behavior type='ECBehaviorComponent'/> <behavior type='ECBehaviorCollider'/> <behavior type='ECBehaviorColliderAI'/> <behavior type='ECBehaviorLocomotion'/> <behavior type='ECBehaviorConversationActor'/> <behavior type='ECBehaviorAlignActor'> <!-- optional: add behavior trees. default adds all behavior trees. --> <list name='behaviorTrees'> <string/> <!-- add behavior with empty identifier --> <string>default</string> <!-- add behavior with 'default' identifier --> </list> <!-- optional: add state machines. default adds all state machines. --> <list name='stateMachines'> <string/> <!-- add behavior with empty identifier --> <string>default</string> <!-- add behavior with 'default' identifier --> </list> <!-- set element properties. omit property prefix if used inside behavior tag --> <float name='.speed'>2</float> </behavior> </elementClass>