{{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.| ====== Behavior Tree Actions ====== This behavior adds these behavior tree actions if behavior tree is present. ===== actorMover.set ===== Set one or more actor mover parameters. ^Parameter^Value^Description^ |limit.turnAngle|float|Limit turn angle in degrees| |limit.turnAngle.enabled|''true'', ''false''|Enable limit turn angle| |speed|float|Movement speed in m/s| |paused|''true'', ''false''|Pause moving to goal| This is an example of using this action: true ===== actorMover.stop ===== Stop moving. This is an example of using this action: ===== 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). ^Parameter^Value^Description^ |goal|''true'', ''false''|Goal is set| |goal.distance.less|float|Distance to goal along path is less than value in meters| |goal.distance.greater|float|Distance to goal along path is greater than value in meters| |limit.turnAngle.enabled|''true'', ''false''|Limit turn angle is enabled| |limit.turnAngle.less|float|Limit turn angle is less than value degrees| |limit.turnAngle.greater|float|Limit turn angle is greater than value degrees| |speed.less|float|Speed is less than value m/s| |speed.greater|float|Speed is greater than value m/s| |paused|''true'', ''false''|Moving 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: true 3 ====== 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. ^Parameter^Value^Description^ |actorMover.goal|''true'', ''false''|Goal is set| |actorMover.goal.distance.less|float|Distance to goal along path is less than value in meters| |actorMover.goal.distance.greater|float|Distance to goal along path is greater than value in meters| |actorMover.limit.turnAngle.enabled|''true'', ''false''|Limit turn angle is enabled| |actorMover.limit.turnAngle.less|float|Limit turn angle is less than value degrees| |actorMover.limit.turnAngle.greater|float|Limit turn angle is greater than value degrees| |actorMover.speed.less|float|Speed is less than value m/s| |actorMover.speed.greater|float|Speed is greater than value m/s| |actorMover.paused|''true'', ''false''|Moving is paused| This is an example of using this condition: true 3 actorMover.check ====== State Machine Actions ====== Same as [[#behavior_tree_actions|Behavior Tree Actions]]. ====== State Machine Conditions ====== Same as [[#behavior_tree_conditions|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 ====== * [[behavior_locomotion|ECBehaviorLocomotion]] * [[behavior_navigator|ECBehaviorNavigator]] ====== Optional Behaviors ====== * [[behavior_rideon|ECBehaviorRideOn]] * [[behavior_conversationactor|ECBehaviorConversationActor]]: Add conversation commands and conditions. * [[behavior_behaviortree|ECBehaviorBehaviorTree]]: Add actions and conditions for behavior trees to use. * [[behavior_statemachine|ECBehaviorStateMachine]]: Add actions and conditions for state machine to use and events to send to the state machine. ====== 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 second second 2 ====== Live Examples ====== * [[https://github.com/LordOfDragons/deexamples|DEExamples Repository]]