{{tag>dragonscript behavior}} [[:start|Start Page]] >> [[main|DragonScript Scripting Language]] >> [[abstractions#behavior_elementsquick_and_easy_development|Behavior Elements: Quick and Easy Development]] >> **ECBehaviorActorAnimated** * [[behaviors_use_cases|Behaviors Explained: By Use-Case]] * [[behaviors_a_to_z|Behaviors Explained: From A to Z]] ====== 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: * [[gamedev:animators|Animators and Animations]] * [[gamedev:deigde:editors:animator|IGDE Animator Editor]] * [[tools:blenderexportscripts|Blender3D Export Scripts]] ====== Instance Counts ====== This behavior can be used only once on an element. ====== Element Class Properties ====== Element class properties have the prefix ''actorAnimated.''. ===== animators ===== Set animators which is a mpa between identifier and animator path. Allows selecting animator to use using the identifier. * Full name: ''actorAnimated.animators'' * Type: map * Default Value: empty string * Example (*.deeclass) default.deanimator sitting.deanimator flying.deanimator ====== Events ====== This behavior has these events: ===== updateControllers ===== Listener can update controllers if required. ===== animationApplied ===== Animation has been applied. ===== animatorChanged ===== Animator changed. Listener has to reacquire AnimatorController. ====== Required Behaviors ====== * [[behavior_component|ECBehaviorComponent]] ====== Optional Behaviors ====== * [[behavior_locomotion|ECBehaviorLocomotion]]: Updates locomotion controller mappings if animator changes. ====== Persistency ====== This behavior does support element class to be persistable (setPersistable). ====== API Documentation ====== #@LinkApiDocDEDS2_HTML~classDragengine_1_1Scenery_1_1ECBehaviorActorAnimated.html,ECBehaviorActorAnimated~@#. Since DragonScript Module Version ''1.0'' ====== Use Cases ====== * Animate actors by seleting animators from a predefined map of animators. * Animate actors using custom runtime assigned animator. ====== Element Class Example ====== 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 ====== Behavior Factory ====== Using element class supporting adding behaviors the behavior can be added like this: second default.deanimator sitting.deanimator flying.deanimator ... ====== Live Examples ====== * [[https://github.com/LordOfDragons/deexamples|DEExamples Repository]]