{{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]] >> **ECBehaviorActorMover**
* [[behaviors_use_cases|Behaviors Explained: By Use-Case]]
* [[behaviors_a_to_z|Behaviors Explained: From A to Z]]
====== ECBehaviorActorMover ======
Behavior adding mover support to actors.
Uses [[behavior_navigator|ECBehaviorNavigator]] to find a path. Uses [[behavior_locomotion|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) 2
====== 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.
^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''.|
====== 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.
^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.|
====== Required Behaviors ======
* [[behavior_locomotion|ECBehaviorLocomotion]]
* [[behavior_navigator|ECBehaviorNavigator]]
====== Optional Behaviors ======
* [[behavior_rideon|ECBehaviorRideOn]]
* [[behavior_conversationactor|ECBehaviorConversationActor]]: Add conversation commands and conditions.
====== Persistency ======
This behavior does support element class to be persistable (setPersistable).
====== API Documentation ======
#@LinkApiDocDEDS2_HTML~classDragengine_1_1Scenery_1_1ECBehaviorActorMover.html,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:
second
2
====== Live Examples ======
* [[https://github.com/LordOfDragons/deexamples|DEExamples Repository]]