Start Page » DragonScript Scripting Language » Abstraction Layers: How you want to build your Game » Behavior Elements » ECBehaviorActorAnimated
Behavior adding animation support to actors.
Adds AnimatorInstance and a map of animators to switch using string identifiers.
To simplify using actor animation a map of controller bindings can be defined to be applied to ECBehaviorLocomotion each time the animator changes. This requires controller names to be consistent and unique across animators but makes life a lot easier. If no map is defined the behavior does not change the locomotion controller mapping. While changing animator controllers with matching names are not reset.
See also:
This behavior can be used only once on an element.
Element class properties have the prefix actorAnimated.
.
Set animators which is a mpa between identifier and animator path. Allows selecting animator to use using the identifier.
actorAnimated.animators
Example (*.deeclass)
<map name='actorAnimated.animators'> <string key='default'>default.deanimator</string> <string key='sitting'>sitting.deanimator</string> <string key='flying'>flying.deanimator</string> </map>
This behavior has these events:
Listener can update controllers if required.
Animation has been applied.
Animator changed. Listener has to reacquire AnimatorController.
This behavior adds these behavior tree actions if behavior tree is present. If behavior has non-empty identifier replace actorAnimated
with actorAnimated(id)
.
Set one or more actor animated parameters.
Parameter | Value | Description |
---|---|---|
animator | string | Set animator by identifier |
controller.name | string | Name of controller to manipulate |
controller.value | float | Set current value of controller controller.name |
controller.value.increment | float | Increment current value of controller controller.name |
controller.value.decrement | float | Decrement current value of controller controller.name |
controller.value.relative | float | Set relative current value of controller controller.name in the range from 0 to 1 |
controller.value.relative.increment | float | Increment relative current value of controller controller.name |
controller.value.relative.decrement | float | Decrement relative current value of controller controller.name |
controller.value.lower | float | Set current value of controller controller.name to lower value |
controller.value.upper | float | Set current value of controller controller.name to upper value |
controller.value.reverse | Reverse current value of controller controller.name . Hence upper becomes lower and vice versa |
This is an example of using this action:
<action name='actorAnimated.set'> <parameter name='animator'>open door</parameter> </action>
Check one or more actor animated parameters. Action succeeds if all parameter value matches their respective actor animated parameter otherwise action fails. This action is typically used as first action in a sequence to run the sequence only if a actor animated parameter matches (or not).
Parameter | Value | Description |
---|---|---|
animator | string | Animator identifier matches string value |
animator.not | string | Animator identifier does not match string value |
animator.starts | string | Animator identifier start with string value |
animator.starts.not | string | Animator identifier does not start with string value |
animator.ends | string | Animator identifier ends with string value |
animator.ends.not | string | Animator identifier does not end with string value |
animator.contains | string | Animator identifier contains string value |
animator.contains.not | string | Animator identifier does not contain string value |
controller.name | string | Name of controller to evaluate |
controller.value.less | float | Current value of controller is less than float value |
controller.value.greater | float | Current value of controller is greater than float value |
controller.value.relative.less | float | Relative current value of controller is less than float value |
controller.value.relative.greater | float | Relative current value of controller is greater than float value |
controller.value.atLower | Current value of controller is at lower value | |
controller.value.atUpper | Current value of controller is at upper value | |
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='actorAnimated.check'> <parameter name='animator'>open door</parameter> </action> <!-- actions here run only if active animator has identifier "open door" --> </sequence>
This behavior adds these behavior tree conditions if behavior tree is present. If behavior has non-empty identifier replace actorAnimated
with actorAnimated(id)
.
Check one or more actor animated parameters. Conditions returns true if all parameter value match their respective actor animated parameter. This condition is typically used to run an action or sequence of actions as long as actor animated conditions are true.
Parameter | Value | Description |
---|---|---|
actorAnimated.animator | string | Animator identifier matches string value |
actorAnimated.animator.not | string | Animator identifier does not match string value |
actorAnimated.animator.starts | string | Animator identifier start with string value |
actorAnimated.animator.starts.not | string | Animator identifier does not start with string value |
actorAnimated.animator.ends | string | Animator identifier ends with string value |
actorAnimated.animator.ends.not | string | Animator identifier does not end with string value |
actorAnimated.animator.contains | string | Animator identifier contains string value |
actorAnimated.animator.contains.not | string | Animator identifier does not contain string value |
actorAnimated.controller.name | string | Name of controller to evaluate |
actorAnimated.controller.value.less | float | Current value of controller is less than float value |
actorAnimated.controller.value.greater | float | Current value of controller is greater than float value |
actorAnimated.controller.value.relative.less | float | Relative current value of controller is less than float value |
actorAnimated.controller.value.relative.greater | float | Relative current value of controller is greater than float value |
actorAnimated.controller.value.atLower | Current value of controller is at lower value | |
actorAnimated.controller.value.atUpper | Current value of controller is at upper value |
This is an example of using this condition:
<action name='myAction' id='doing something'> <parameter name='actorAnimated.animator'>open door</parameter> <condition>actorAnimated.check</condition> </action>
Same as Behavior Tree Actions.
Same as Behavior Tree Conditions.
This behavior sends these state machine events. If behavior has non-empty identifier replace actorAnimated
with actorAnimated(id)
.
This behavior has these events:
Animator changed.
This behavior does support element class to be persistable (setPersistable).
Since DragonScript Module Version 1.0
This example defines an element which animated an actor.
class MyElement extends BehaviorElementClass public var ECBehaviorComponent component public var ECBehaviorCollider collider public var ECBehaviorColliderAI colliderAI public var ECBehaviorLocomotion locomotion public var ECBehaviorActorAnimated actorAnimated func new() component = ECBehaviorComponent.new(this, null) collider = ECBehaviorCollider.new(this, component) colliderAI = ECBehaviorColliderAI.new(this, collider) locomotion = ECBehaviorLocomotion.new(this, colliderAI) actorAnimatord = ECBehaviorActorAnimated.new(this, component, locomotion) 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='ECBehaviorActorAnimated'> <!-- optional: use component with id instead of empty string --> <string name='component'>second</string> <!-- optional: use behavior tree with id instead of empty string --> <string name='behaviorTree'>second</string> <!-- optional: use state machine with id instead of empty string --> <string name='stateMachine'>second</string> <!-- optional: set controller mapping instead of using default mapping. keys are the controller names and value the LocomotionAttribute constant names. the listing below is equivalent to the default controller mapping. --> <map name='controllerMapping'> <string key='idle'>elapsedTime</string> <string key='look.vertical'>lookVertical</string> <string key='look.horizontal'>lookHorizontal</string> <string key='turn.inPlace'>timeTurnIP</string> <string key='turn.velocity'>turningSpeed</string> <string key='stance'>stance</string> <string key='move.walk'>displacement</string> <string key='move.run'>displacement</string> <string key='move.velocity'>relativeMovingSpeed</string> <string key='tilt.vertical'>tiltVertical</string> <string key='tilt.horizontal'>tiltHorizontal</string> <string key='tilt.offset'>tiltOffset</string> <string key='interaction'>elapsedTime</string> </map> <!-- set element properties. omit property prefix if used inside behavior tag --> <map name='.animators'> <string key='default'>default.deanimator</string> <string key='sitting'>sitting.deanimator</string> <string key='flying'>flying.deanimator</string> </map> </behavior> <!-- for adding multiple behaviors use unique identifiers --> <behavior type='ECBehaviorActorAnimated' id='second'> ... </behavior> </elementClass>