Table of Contents

,

Start Page » DragonScript Scripting Language » Behavior Elements: Quick and Easy Development » ECBehaviorActorAnimated

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:

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.

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

Optional Behaviors

Persistency

This behavior does support element class to be persistable (setPersistable).

API Documentation

ECBehaviorActorAnimated.

Since DragonScript Module Version 1.0

Use Cases

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:

<?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>

Live Examples