This is an old revision of the document!
Start Page » DragonScript Scripting Language » Abstraction Layers: How you want to build your Game » Behavior Elements » ECBehaviorPlayerInputMove
Behavior element behavior adding moving player input.
Keeps track of moving player input and applies them to actor locomotion. The type of locomotion can be set to one of three typical configurations.
This behavior can be used for human actor and vehicle movement.
This behavior can be used only once on an element.
Element class properties have the prefix playerInputMove.
.
Set walk speed in meters per second.
playerInputMove.speedWalk
1.25
0
<float name='playerInputMove.speedWalk'>1.5</float>
Set run speed in meters per second.
playerInputMove.speedRun
4
0
<float name='playerInputMove.speedRun'>6</float>
Set speed factor walking forward.
playerInputMove.speedFactorWalkForward
1
0
<float name='playerInputMove.speedFactorWalkForward'>6</float>
Set speed factor walking backward.
playerInputMove.speedFactorWalkBackward
1
0
<float name='playerInputMove.speedFactorWalkBackward'>6</float>
Set speed factor walking left.
playerInputMove.speedFactorWalkLeft
1
0
<float name='playerInputMove.speedFactorWalkLeft'>6</float>
Set speed factor walking right.
playerInputMove.speedFactorWalkRight
1
0
<float name='playerInputMove.speedFactorWalkRight'>6</float>
Set speed factor running forward.
playerInputMove.speedFactorRunForward
1
0
<float name='playerInputMove.speedFactorRunForward'>6</float>
Set speed factor running backward.
playerInputMove.speedFactorRunBackward
1
0
<float name='playerInputMove.speedFactorRunBackward'>6</float>
Set speed factor running left.
playerInputMove.speedFactorRunLeft
1
0
<float name='playerInputMove.speedFactorRunLeft'>6</float>
Set speed factor running right.
playerInputMove.speedFactorRunRight
1
0
<float name='playerInputMove.speedFactorRunRight'>6</float>
This behavior has no events.
This behavior adds these behavior tree actions if behavior tree is present.
Set one or more player input move parameters.
Parameter | Value | Description | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
reset | empty string, analog | Reset player input move. If analog is set only resets analog values |
||||||||||||
locomotion.type | natural , fps , vehicle | Locomotion type:
|
||||||||||||
forward | true , false | Move forward key pressed | ||||||||||||
forward.toggle | Toggle move forward key pressed | |||||||||||||
backward | true , false | Move backward key pressed | ||||||||||||
backward.toggle | Toggle move backward key pressed | |||||||||||||
left | true , false | Move left key pressed | ||||||||||||
left.toggle | Toggle move left key pressed | |||||||||||||
right | true , false | Move right key pressed | ||||||||||||
right.toggle | Toggle move right key pressed | |||||||||||||
analog.forwardBackward | float, eventParam , -eventParam | Analog move forward/backward value | ||||||||||||
analog.forwardBackward.sticky, eventParam , -eventParam | float | Sticky analog move forward/backward value | ||||||||||||
analog.leftRight | float, eventParam , -eventParam | Analog move left/right value | ||||||||||||
analog.leftRight.sticky | float, eventParam , -eventParam | Sticky analog move left/right value | ||||||||||||
canMove | true , false | Can move | ||||||||||||
canMove.toggle | Toggle can move | |||||||||||||
run | true , false | Run key pressed | ||||||||||||
run.toggle | Toggle run key pressed | |||||||||||||
speed.walk | float | Walk speed in m/s | ||||||||||||
speed.walk.forward | float | Walk forward speed multiplicator | ||||||||||||
speed.walk.backward | float | Walk backward speed multiplicator | ||||||||||||
speed.walk.left | float | Walk left speed multiplicator | ||||||||||||
speed.walk.right | float | Walk right speed multiplicator | ||||||||||||
speed.run | float | Run speed in m/s | ||||||||||||
speed.run.forward | float | Run forward speed multiplicator | ||||||||||||
speed.run.backward | float | Run backward speed multiplicator | ||||||||||||
speed.run.left | float | Run left speed multiplicator | ||||||||||||
speed.run.right | float | Run right speed multiplicator | ||||||||||||
moving.direction | float | Moving direction in the range from -180 to 180 degrees | ||||||||||||
moving.speed | float | Moving speed in m/s |
This is an example of using this action:
<action name='playerInputMove.set'> <parameter name='forward'>true</parameter> </action>
Check one or more player input move parameters. Action succeeds if all parameter value matches their respective player input move parameter otherwise action fails. This action is typically used as first action in a sequence to run the sequence only if a player input move parameter matches (or not).
Parameter | Value | Description |
---|---|---|
locomotion.type | natural , fps , vehicle | Locomtion type matches value |
locomotion.type.not | natural , fps , vehicle | Locomtion type does not match value |
forward | true , false | Move forward key pressed |
backward | true , false | Move backward key pressed |
left | true , false | Move left key pressed |
right | true , false | Move right key pressed |
analog.forwardBackward.less | float | Analog move forward/backward value is less than value |
analog.forwardBackward.greater | float | Analog move forward/backward value is greater than value |
analog.forwardBackward.sticky.less | float | Sticky analog move forward/backward value is less than value |
analog.forwardBackward.sticky.greater | float | Sticky analog move forward/backward value is greater than value |
analog.leftRight.less | float | Analog move left/right value is less than value |
analog.leftRight.greater | float | Analog move left/right value is greater than value |
analog.leftRight.sticky.less | float | Sticky analog move left/right value is less than value |
analog.leftRight.sticky.greater | float | Sticky analog move left/right value is greater than value |
canMove | true , false | Can move |
moving | true , false | Player is moving meaning canMove is true and at least one movement key is pressed |
run | true , false | Run key pressed |
speed.walk.less | float | Walk speed is less than float value m/s |
speed.walk.greater | float | Walk speed is greater than float value m/s |
speed.walk.forward.less | float | Walk forward multiplicator is less than float value m/s |
speed.walk.forward.greater | float | Walk forward multiplicator is greater than float value m/s |
speed.walk.backward.less | float | Walk backward multiplicator is less than float value m/s |
speed.walk.backward.greater | float | Walk backward multiplicator is greater than float value m/s |
speed.walk.left.less | float | Walk left multiplicator is less than float value m/s |
speed.walk.left.greater | float | Walk left multiplicator is greater than float value m/s |
speed.walk.right.less | float | Walk right multiplicator is less than float value m/s |
speed.run.right.greater | float | Run right multiplicator is greater than float value m/s |
speed.run.less | float | Run speed is less than float value m/s |
speed.run.greater | float | Run speed is greater than float value m/s |
speed.run.forward.less | float | Run forward multiplicator is less than float value m/s |
speed.run.forward.greater | float | Run forward multiplicator is greater than float value m/s |
speed.run.backward.less | float | Run backward multiplicator is less than float value m/s |
speed.run.backward.greater | float | Run backward multiplicator is greater than float value m/s |
speed.run.left.less | float | Run left multiplicator is less than float value m/s |
speed.run.left.greater | float | Run left multiplicator is greater than float value m/s |
speed.run.right.less | float | Run right multiplicator is less than float value m/s |
speed.run.right.greater | float | Run right multiplicator is greater than float value m/s |
moving.direction | float | Moving direction in the range from -180 to 180 degrees. Requires moving.direction.less or moving.direction.greater to be set |
moving.direction.less | float | Difference between moving.direction and moving direction is less than degree value |
moving.direction.greater | float | Difference between moving.direction and moving direction is greater than degree value |
moving.speed.less | float | Moving speed is less than float value m/s |
moving.speed.greater | float | Moving speed is greater than float value m/s |
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='playerInputMove.check'> <parameter name='left'>true</parameter> </action> <!-- actions here run only if moving left key is pressed --> </sequence>
This behavior adds these behavior tree conditions if behavior tree is present.
Check one or more player input move parameters. Conditions returns true if all parameter value match their respective player input move parameter. This condition is typically used to run an action or sequence of actions as long as player input move conditions are true.
Parameter | Value | Description |
---|---|---|
playerInputMove.locomotion.type | natural , fps , vehicle | Locomtion type matches value |
playerInputMove.locomotion.type.not | natural , fps , vehicle | Locomtion type does not match value |
playerInputMove.forward | true , false | Move forward key pressed |
playerInputMove.backward | true , false | Move backward key pressed |
playerInputMove.left | true , false | Move left key pressed |
playerInputMove.right | true , false | Move right key pressed |
playerInputMove.analog.forwardBackward.less | float | Analog move forward/backward value is less than value |
playerInputMove.analog.forwardBackward.greater | float | Analog move forward/backward value is greater than value |
playerInputMove.analog.forwardBackward.sticky.less | float | Sticky analog move forward/backward value is less than value |
playerInputMove.analog.forwardBackward.sticky.greater | float | Sticky analog move forward/backward value is greater than value |
playerInputMove.analog.leftRight.less | float | Analog move left/right value is less than value |
playerInputMove.analog.leftRight.greater | float | Analog move left/right value is greater than value |
playerInputMove.analog.leftRight.sticky.less | float | Sticky analog move left/right value is less than value |
playerInputMove.analog.leftRight.sticky.greater | float | Sticky analog move left/right value is greater than value |
playerInputMove.canMove | true , false | Can move |
playerInputMove.moving | true , false | Player is moving meaning canMove is true and at least one movement key is pressed |
playerInputMove.run | true , false | Run key pressed |
playerInputMove.speed.walk.less | float | Walk speed is less than float value m/s |
playerInputMove.speed.walk.greater | float | Walk speed is greater than float value m/s |
playerInputMove.speed.walk.forward.less | float | Walk forward multiplicator is less than float value m/s |
playerInputMove.speed.walk.forward.greater | float | Walk forward multiplicator is greater than float value m/s |
playerInputMove.speed.walk.backward.less | float | Walk backward multiplicator is less than float value m/s |
playerInputMove.speed.walk.backward.greater | float | Walk backward multiplicator is greater than float value m/s |
playerInputMove.speed.walk.left.less | float | Walk left multiplicator is less than float value m/s |
playerInputMove.speed.walk.left.greater | float | Walk left multiplicator is greater than float value m/s |
playerInputMove.speed.walk.right.less | float | Walk right multiplicator is less than float value m/s |
playerInputMove.speed.run.right.greater | float | Run right multiplicator is greater than float value m/s |
playerInputMove.speed.run.less | float | Run speed is less than float value m/s |
playerInputMove.speed.run.greater | float | Run speed is greater than float value m/s |
playerInputMove.speed.run.forward.less | float | Run forward multiplicator is less than float value m/s |
playerInputMove.speed.run.forward.greater | float | Run forward multiplicator is greater than float value m/s |
playerInputMove.speed.run.backward.less | float | Run backward multiplicator is less than float value m/s |
playerInputMove.speed.run.backward.greater | float | Run backward multiplicator is greater than float value m/s |
playerInputMove.speed.run.left.less | float | Run left multiplicator is less than float value m/s |
playerInputMove.speed.run.left.greater | float | Run left multiplicator is greater than float value m/s |
playerInputMove.speed.run.right.less | float | Run right multiplicator is less than float value m/s |
playerInputMove.speed.run.right.greater | float | Run right multiplicator is greater than float value m/s |
playerInputMove.moving.direction | float | Moving direction in the range from -180 to 180 degrees. Requires moving.direction.less or moving.direction.greater to be set |
playerInputMove.moving.direction.less | float | Difference between moving.direction and moving direction is less than degree value |
playerInputMove.moving.direction.greater | float | Difference between moving.direction and moving direction is greater than degree value |
playerInputMove.moving.speed.less | float | Moving speed is less than float value m/s |
playerInputMove.moving.speed.greater | float | Moving speed is greater than float value m/s |
This is an example of using this condition:
<action name='myAction' id='doing something'> <parameter name='playerInputMove.left'>true</parameter> <condition>playerInputMove.check</condition> </action>
Same as Behavior Tree Actions.
Same as Behavior Tree Conditions.
This behavior send no events to state machine.
This behavior requires no other behaviors.
This behavior does not required element class to be persistable (setPersistable).
Since DragonScript Module Version 1.0
This example defines an element which tracks player moving input.
class MyElement extends BehaviorElementClass public var ECBehaviorPlayerInputMove playerInputMove func new() playerInputMove = ECBehaviorPlayerInputMove.new(this) 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='ECBehaviorPlayerInputMove'> <!-- optional: set locomotion type. default is 'natural'. allowed values are these: natural: default locomotion working best for actors moving in a natural way. The actor moves into the direction it is looking. The body is oriented into the walking direction if the actor is moving. fps: configuration useful for FPS type games where the actor is always oriented into the direction the player is looking. This configuration typically uses an 8-direction animator representing the actor moving into any direction relative to the looking direction. vehicle: configuration useful for vehicle type actors like tanks which move into the direction their body is oriented while allowing to freely look around. --> <string name='locomotionType'>natural</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 --> <string name='.name'>Color 1</string> </behavior> </elementClass>