Start Page » DragonScript Scripting Language » Abstraction Layers: How you want to build your Game » Behavior Elements » ECBehaviorLocomotion
Behavior element behavior adding locomotion support for actors.
Adds Locomotion. Actors use Locomotion to move their AI colliders across the game world. Locomotion also provides values for AnimatorController to provide animation to actors matching their movement.
Uses collider of ECBehaviorColliderAI or ECBehaviorCollider depending which one is present. If both are present ECBehaviorColliderAI is preferred.
By default creates instance of Locomotion. This class provides all the basic behavior to do locomotion for different type of actors. Supports organic locomotion of 2-legged and 4-legged characters with natural and FPS type movement patterns as well as mechanical locomotion like vehicles.
Locomotion parameters have to be set on runtime. The behavior itself does not support initializing locomotion parameters. This is the case since locomotion parameters change a lot depending on what game situation an actor is located in. Use ECBehaviorActorAIAction, ECBehaviorStateMachine or ECBehaviorBehaviorTree for this task.
The ECBehaviorLocomotion provides access to the locomotion class to modify at runtime.
See also:
This behavior can be used only once on an element.
Element class properties have the prefix locomotion.
.
This behavior has no events.
This behavior does not support optional behaviors.
This behavior does support element class to be persistable (setPersistable). Saves locomotion state.
Since DragonScript Module Version 1.0
This example defines an element which supports locomotion for actors. For vehicles omit ECBehaviorColliderAI and use ECBehaviorCollider instead.
class MyElement extends BehaviorElementClass public var ECBehaviorComponent component public var ECBehaviorCollider collider public var ECBehaviorColliderAI colliderAI public var ECBehaviorLocomotion locomotion func new() component = ECBehaviorComponent.new(this, null) collider = ECBehaviorCollider.new(this, component) colliderAI = ECBehaviorColliderAI.new(this, collider) locomotion = ECBehaviorLocomotion.new(this, colliderAI) 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'/> <!-- for vehicles omit this line to use ECBehaviorCollider instead --> <behavior type='ECBehaviorColliderAI'/> <behavior type='ECBehaviorLocomotion'> <!-- set element properties. omit property prefix if used inside behavior tag --> <string name='.name'>value</string> </behavior> </elementClass>