{{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]] >> **ECBehaviorLocomotion** * [[behaviors_use_cases|Behaviors Explained: By Use-Case]] * [[behaviors_a_to_z|Behaviors Explained: From A to Z]] ====== 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 [[behavior_colliderai|ECBehaviorColliderAI]] or [[behavior_collider|ECBehaviorCollider]] depending which one is present. If both are present [[behavior_colliderai|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 [[behavior_actoraiaction|ECBehaviorActorAIAction]], [[behavior_statemachine|ECBehaviorStateMachine]] or [[behavior_behaviortree|ECBehaviorBehaviorTree]] for this task. The ECBehaviorLocomotion provides access to the #@LinkApiDocDEDS2_HTML~classDragengine_1_1Scenery_1_1Locomotion.html,locomotion class~@# to modify at runtime. See also: * [[dragengine:modules:dragonscript:locomotion|Locomotion]] ====== Instance Counts ====== This behavior can be used only once on an element. ====== Element Class Properties ====== Element class properties have the prefix ''locomotion.'' . ====== Events ====== This behavior has no events. ====== Required Behaviors ====== * [[behavior_colliderai|ECBehaviorColliderAI]] or [[behavior_collider|ECBehaviorCollider]] ====== Optional Behaviors ====== This behavior does not support optional behaviors. ====== Persistency ====== This behavior does support element class to be persistable (setPersistable). Saves locomotion state. ====== API Documentation ====== #@LinkApiDocDEDS2_HTML~classDragengine_1_1Scenery_1_1ECBehaviorLocomotion.html,ECBehaviorLocomotion~@#. Since DragonScript Module Version ''1.0'' ====== Use Cases ====== * Add support for FPS/natural type locomotion to human/creature actors. * Add support for vehicle type locomotion to vehicles. ====== Element Class Example ====== This example defines an element which supports locomotion for actors. For vehicles omit [[behavior_colliderai|ECBehaviorColliderAI]] and use [[behavior_collider|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 ====== Behavior Factory ====== Using element class supporting adding behaviors the behavior can be added like this: value ====== Live Examples ====== * [[https://github.com/LordOfDragons/deexamples|DEExamples Repository]]