Table of Contents

,

Start Page » DragonScript Scripting Language » Abstraction Layers: How you want to build your Game » Behavior Elements » ECBehaviorActorMover

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.

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.

Behavior Tree Actions

This behavior adds these behavior tree actions if behavior tree is present.

actorMover.set

Set one or more actor mover parameters.

ParameterValueDescription
limit.turnAnglefloatLimit turn angle in degrees
limit.turnAngle.enabledtrue, falseEnable limit turn angle
speedfloatMovement speed in m/s
pausedtrue, falsePause moving to goal

This is an example of using this action:

<action name='actorMover.set'>
  <parameter name='paused'>true</parameter>
</action>

actorMover.stop

Stop moving.

This is an example of using this action:

<action name='actorMover.stop'/>

actorMover.check

Check one or more actor mover parameters. Action succeeds if all parameter value matches their respective actor mover parameter otherwise action fails. This action is typically used as first action in a sequence to run the sequence only if a actor mover parameter matches (or not).

ParameterValueDescription
goaltrue, falseGoal is set
goal.distance.lessfloatDistance to goal along path is less than value in meters
goal.distance.greaterfloatDistance to goal along path is greater than value in meters
limit.turnAngle.enabledtrue, falseLimit turn angle is enabled
limit.turnAngle.lessfloatLimit turn angle is less than value degrees
limit.turnAngle.greaterfloatLimit turn angle is greater than value degrees
speed.lessfloatSpeed is less than value m/s
speed.greaterfloatSpeed is greater than value m/s
pausedtrue, falseMoving is paused
wait If present action returns BTResult.running instead of BTResult.failed to wait until the checks are all fulfilled

This is an example of using this action:

<sequence>
  <action name='actorMover.check'>
    <parameter name='goal'>true</parameter>
    <parameter name='goal.distance.less'>3</parameter>
  </action>
  <!-- actions here run only if actor mover has goal set and actor is less than 3 meters near to it -->
</sequence>

Behavior Tree Conditions

This behavior adds these behavior tree conditions if behavior tree is present.

actorMover.check

Check one or more actor mover parameters. Conditions returns true if all parameter value match their respective actor mover parameter. This condition is typically used to run an action or sequence of actions as long as actor mover conditions are true.

ParameterValueDescription
actorMover.goaltrue, falseGoal is set
actorMover.goal.distance.lessfloatDistance to goal along path is less than value in meters
actorMover.goal.distance.greaterfloatDistance to goal along path is greater than value in meters
actorMover.limit.turnAngle.enabledtrue, falseLimit turn angle is enabled
actorMover.limit.turnAngle.lessfloatLimit turn angle is less than value degrees
actorMover.limit.turnAngle.greaterfloatLimit turn angle is greater than value degrees
actorMover.speed.lessfloatSpeed is less than value m/s
actorMover.speed.greaterfloatSpeed is greater than value m/s
actorMover.pausedtrue, falseMoving is paused

This is an example of using this condition:

<action name='myAction' id='doing something'>
  <parameter name='actorMover.goal'>true</parameter>
  <parameter name='actorMover.goal.distance.less'>3</parameter>
  <condition>actorMover.check</condition>
</action>

State Machine Actions

Same as Behavior Tree Actions.

State Machine Conditions

Same as Behavior Tree Conditions.

State Machine Events

This behavior sends these state machine events.

actorMover.start

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 actorMover.arrived and actorMover.stop is send too.

actorMover.stop

Actor stops moving.

actorMover.arrived

Actor arrived at goal position. actorMover.stop will be send before this event.

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

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>
 
    <!-- optional: use behavior tree with id instead of empty string -->
    <string name='behaviorTree'>second</string>
 
    <!-- optional: use state machine with id instead of empty string -->
    <string name='stateMachine'>second</string>
 
    <!-- set element properties. omit property prefix if used inside behavior tag -->
    <float name='.speed'>2</float>
  </behavior>
</elementClass>

Live Examples