User Tools

Site Tools


dragengine:modules:dragonscript:behavior_locomotion

This is an old revision of the document!


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:

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

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

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

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'/>
 
  <!-- 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>

Live Examples

You could leave a comment if you were logged in.
dragengine/modules/dragonscript/behavior_locomotion.1741808382.txt.gz · Last modified: 2025/03/12 19:39 by dragonlord