User Tools

Site Tools


dragengine:modules:dragonscript:behavior_actormover

ECBehaviorActorMover

Behavior adding mover support to actors.

Uses ECBehaviorNavigator to find a path. Uses ECBehaviorLocomotion to provide input to the actor for the direction to move to. Listener tell the actor and other behavior about the state of moving towards the goal.

Instance Counts

This behavior can be used only once on an element.

Element Class Properties

Element class properties have the prefix actorMover..

speed

Set moving speed in meters per second.

  • Full name: actorMover.speed
  • Type: float
  • Default Value: 1.25
  • Restriction: At least 0
  • Example (*.deeclass)
    <float name='actorMover.speed'>2</float>

Events

This behavior has these events:

startMoving

Actor starts moving towards goal. Path can be null if no path could be found or the actor is already at the goal. In this case arrivedAtGoal and stopMoving will be send too.

stopMoving

Actor stops moving.

arrivedAtGoal

Actor arrived at goal position. stopMoving will be send before arrivedAtGoal is send.

modifyMoveTowards

Listener can modify locomotion values set by behavior before sending this event.

Conversation Commands

This behavior adds these conversation commands.

actorMover

Control actor mover. The following syntax is supported:

actorMover pause

Pause moving if a goal is set.

actorMover continue

Continue moving if a goal is set.

actorMover stop

Stop moving if a goal is set.

actorMover actor [id] [distance]

Start moving to position of conversation actor.

ParameterDescription
idIdentifier or Alias of conversation actor. Throws exception conversation actor has no playback or actor id/alias is unknown.
distanceStops moving as soon as the remaining distance in meters to goal is less than or equal to distance.

actorMover coordsys [id] [distance]

Start moving to position of conversation coordinate system.

ParameterDescription
idIdentifier of conversation coord system to use. Throws exception conversation actor has no playback or identifier is unknown.
distanceStops moving as soon as the remaining distance in meters to goal is less than or equal to distance.

actorMover spawn [name] [distance]

Start moving to position of spawn point.

ParameterDescription
nameName of spawn point to use. Throws exception element is not in a game world or name is not found in the game world.
distanceStops moving as soon as the remaining distance in meters to goal is less than or equal to distance.

actorMover anchor [id] [distance]

Start moving to position of anchor element.

ParameterDescription
idIdentifier of anchor element to use. Throws exception element is not in a game world or name is not found in the game world.
distanceStops moving as soon as the remaining distance in meters to goal is less than or equal to distance.

actorMover position [x] [y] [z] [distance]

Start moving to position in game world.

ParameterDescription
x,y,zCoordinates of position to move to.
distanceStops moving as soon as the remaining distance in meters to goal is less than or equal to distance.

actorMover relative [offsetX] [offsetY] [offsetZ] [distance]

Start moving to position relative to current position.

ParameterDescription
offset*Position relative to element matrix.
distanceStops moving as soon as the remaining distance in meters to goal is less than or equal to distance.

Conversation Conditions

This behavior adds these conversation conditions.

actorMover

actorMover hasGoal

Goal is set.

actorMover hasNoGoal

Goal is not set.

paused

Moving is paused.

actorMover closerThan [goal | direct] [distance]

Checks if the test distance is less than or equal to distance. If no goal is set true is returned. The remaining goal distance is not necessarily the same as the direct line distance between the actor and the goal.

ParameterDescription
goalUse remaining goal distance as test distance.
directUse distance between actor and goal position as test distance.
distanceDistance to test against.

Required Behaviors

Optional Behaviors

Persistency

This behavior does support element class to be persistable (setPersistable).

API Documentation

ECBehaviorActorMover.

Since DragonScript Module Version 1.0

Use Cases

  • Move actor along navigation spaces using navigator.

Element Class Example

This example defines an element which can be moved using navigator.

class MyElement extends BehaviorElementClass
  public var ECBehaviorComponent component
  public var ECBehaviorCollider collider
  public var ECBehaviorColliderAI colliderAI
  public var ECBehaviorLocomotion locomotion
  public var ECBehaviorNavigator navigator
  public var ECBehaviorProjectToGround projectToGround
  public var ECBehaviorRideOn rideOn
  public var ECBehaviorConversationActor conversationActor
  public var ECBehaviorActorMover actorMover
  func new()
    component = ECBehaviorComponent.new(this, null)
    collider = ECBehaviorCollider.new(this, component)
    colliderAI = ECBehaviorColliderAI.new(this, collider)
    locomotion = ECBehaviorLocomotion.new(this, colliderAI)
    navigator = ECBehaviorNavigator.new(this)
    projectToGround = ECBehaviorProjectToGround.new(this, colliderAI)
    rideOn = ECBehaviorRideOn.new(this, locomotion, projectToGround)
    conversationActor = ECBehaviorConversationActor.new(this)
    actorMover = ECBehaviorActorMover.new(this, locomotion, navigator, rideOn)
    actorMover.setConversationActor(conversationActor)
  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'/>
  <behavior type='ECBehaviorColliderAI'/>
  <behavior type='ECBehaviorLocomotion'/>
  <behavior type='ECBehaviorNavigator'/>
  <behavior type='ECBehaviorProjectToGround'/>
  <behavior type='ECBehaviorRideOn'/>
  <behavior type='ECBehaviorConversationActor'/>
 
  <behavior type='ECBehaviorActorMover'>
    <!-- optional: use navigator with id instead of empty string -->
    <string name='navigator'>second</string>
 
    <!-- set element properties. omit property prefix if used inside behavior tag -->
    <float name='.speed'>2</float>
  </behavior>
</elementClass>

Live Examples

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