Start Page » DragonScript Scripting Language » Behavior Elements: Quick and Easy Development » 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.
This behavior can be used only once on an element.
Element class properties have the prefix actorMover.
.
Set moving speed in meters per second.
actorMover.speed
<float name='actorMover.speed'>2</float>
This behavior has these events:
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.
Actor stops moving.
Actor arrived at goal position. stopMoving
will be send before arrivedAtGoal
is send.
Listener can modify locomotion values set by behavior before sending this event.
This behavior adds these conversation commands.
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.
Parameter | Description |
---|---|
id | Identifier or Alias of conversation actor. Throws exception conversation actor has no playback or actor id/alias is unknown. |
distance | Stops 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.
Parameter | Description |
---|---|
id | Identifier of conversation coord system to use. Throws exception conversation actor has no playback or identifier is unknown. |
distance | Stops 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.
Parameter | Description |
---|---|
name | Name of spawn point to use. Throws exception element is not in a game world or name is not found in the game world. |
distance | Stops 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.
Parameter | Description |
---|---|
id | Identifier of anchor element to use. Throws exception element is not in a game world or name is not found in the game world. |
distance | Stops 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.
Parameter | Description |
---|---|
x,y,z | Coordinates of position to move to. |
distance | Stops 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.
Parameter | Description |
---|---|
offset* | Position relative to element matrix. |
distance | Stops moving as soon as the remaining distance in meters to goal is less than or equal to distance . |
This behavior adds these conversation conditions.
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.
Parameter | Description |
---|---|
goal | Use remaining goal distance as test distance. |
direct | Use distance between actor and goal position as test distance. |
distance | Distance to test against. |
This behavior does support element class to be persistable (setPersistable).
Since DragonScript Module Version 1.0
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
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>