Start Page » DragonScript Scripting Language » Behavior Elements: Quick and Easy Development » 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 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> <!-- 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>