Start Page » DragonScript Scripting Language » Behavior Elements: Quick and Easy Development » ECBehaviorAlignActor
Behavior adding support to actors to align to a specific position and orientation.
Manipulates ECBehaviorLocomotion to move an actor a short distance to a specific position, orientation and looking direction. This is typically required for actors intending to interact with objects. In this case the animation of the actor has to match the object it is interacting with. Actor actions will use this behavior to achieve this goal.
This behavior can be used only once on an element.
Element class properties have the prefix alignActor.
.
Set movement speed while aligning in meters per seconds.
alignActor.speed
<float name='alignActor.speed'>2</float>
This behavior has these events:
Actor starts aligning.
Actor finished aligning.
This behavior does support element class to be persistable (setPersistable).
Since DragonScript Module Version 1.0
This example defines an element which supports aligning actor.
class MyElement extends BehaviorElementClass public var ECBehaviorComponent component public var ECBehaviorCollider collider public var ECBehaviorColliderAI colliderAI public var ECBehaviorLocomotion locomotion public var ECBehaviorConversationActor conversationActor public var ECBehaviorAlignActor alignActor func new() component = ECBehaviorComponent.new(this, null) collider = ECBehaviorCollider.new(this, component) colliderAI = ECBehaviorColliderAI.new(this, collider) locomotion = ECBehaviorLocomotion.new(this, colliderAI) conversationActor = ECBehaviorConversationActor.new(this) alignActor = ECBehaviorAlignActor.new(this, locomotion, conversationActor) 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='ECBehaviorColliderAI'/> <behavior type='ECBehaviorLocomotion'/> <behavior type='ECBehaviorConversationActor'/> <behavior type='ECBehaviorAlignActor'> <!-- set element properties. omit property prefix if used inside behavior tag --> <float name='.speed'>2</float> </behavior> </elementClass>