{{tag>dragonscript behavior}}
[[:start|Start Page]] >> [[main|DragonScript Scripting Language]] >> [[dragengine:modules:dragonscript:abstractions|Abstraction Layers: How you want to build your Game]] >> [[dragengine:modules:dragonscript:behavior_elements|Behavior Elements]] >> **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)
====== 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.
====== Behavior Tree Actions ======
This behavior adds these behavior tree actions if behavior tree is present. If behavior has non-empty identifier replace ''actorAnimated'' with ''actorAnimated(id)''.
===== actorAnimated.set =====
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:
open door
===== actorAnimated.check =====
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:
open door
====== Behavior Tree Conditions ======
This behavior adds these behavior tree conditions if behavior tree is present. If behavior has non-empty identifier replace ''actorAnimated'' with ''actorAnimated(id)''.
===== actorAnimated.check =====
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:
open door
actorAnimated.check
====== State Machine Actions ======
Same as [[#behavior_tree_actions|Behavior Tree Actions]].
====== State Machine Conditions ======
Same as [[#behavior_tree_conditions|Behavior Tree Conditions]].
====== State Machine Events ======
This behavior sends these state machine events. If behavior has non-empty identifier replace ''actorAnimated'' with ''actorAnimated(id)''.
This behavior has these events:
===== actorAnimated.animator =====
Animator changed.
====== Required Behaviors ======
* [[behavior_component|ECBehaviorComponent]]
====== Optional Behaviors ======
* [[behavior_locomotion|ECBehaviorLocomotion]]: Updates locomotion controller mappings if animator changes.
* [[behavior_behaviortree|ECBehaviorBehaviorTree]]: Add actions and conditions for behavior trees to use.
* [[behavior_statemachine|ECBehaviorStateMachine]]: Add actions and conditions for state machine to use and events to send to the state machine.
====== 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
second
second
...
====== Live Examples ======
* [[https://github.com/LordOfDragons/deexamples|DEExamples Repository]]