User Tools

Site Tools


dragengine:modules:dragonscript:bahevior_playerinputmove

This is an old revision of the document!


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.

Instance Counts

This behavior can be used only once on an element.

Element Class Properties

Element class properties have the prefix playerInputMove. .

speedWalk

Set walk speed in meters per second.

  • Full name: playerInputMove.speedWalk
  • Type: float
  • Default Value: 1.25
  • Restriction: At least 0
  • Example (*.deeclass)
    <float name='playerInputMove.speedWalk'>1.5</float>

speedRun

Set run speed in meters per second.

  • Full name: playerInputMove.speedRun
  • Type: float
  • Default Value: 4
  • Restriction: At least 0
  • Example (*.deeclass)
    <float name='playerInputMove.speedRun'>6</float>

speedFactorWalkForward

Set speed factor walking forward.

  • Full name: playerInputMove.speedFactorWalkForward
  • Type: float
  • Default Value: 1
  • Restriction: At least 0
  • Example (*.deeclass)
    <float name='playerInputMove.speedFactorWalkForward'>6</float>

speedFactorWalkBackward

Set speed factor walking backward.

  • Full name: playerInputMove.speedFactorWalkBackward
  • Type: float
  • Default Value: 1
  • Restriction: At least 0
  • Example (*.deeclass)
    <float name='playerInputMove.speedFactorWalkBackward'>6</float>

speedFactorWalkLeft

Set speed factor walking left.

  • Full name: playerInputMove.speedFactorWalkLeft
  • Type: float
  • Default Value: 1
  • Restriction: At least 0
  • Example (*.deeclass)
    <float name='playerInputMove.speedFactorWalkLeft'>6</float>

speedFactorWalkRight

Set speed factor walking right.

  • Full name: playerInputMove.speedFactorWalkRight
  • Type: float
  • Default Value: 1
  • Restriction: At least 0
  • Example (*.deeclass)
    <float name='playerInputMove.speedFactorWalkRight'>6</float>

speedFactorRunForward

Set speed factor running forward.

  • Full name: playerInputMove.speedFactorRunForward
  • Type: float
  • Default Value: 1
  • Restriction: At least 0
  • Example (*.deeclass)
    <float name='playerInputMove.speedFactorRunForward'>6</float>

speedFactorRunBackward

Set speed factor running backward.

  • Full name: playerInputMove.speedFactorRunBackward
  • Type: float
  • Default Value: 1
  • Restriction: At least 0
  • Example (*.deeclass)
    <float name='playerInputMove.speedFactorRunBackward'>6</float>

speedFactorRunLeft

Set speed factor running left.

  • Full name: playerInputMove.speedFactorRunLeft
  • Type: float
  • Default Value: 1
  • Restriction: At least 0
  • Example (*.deeclass)
    <float name='playerInputMove.speedFactorRunLeft'>6</float>

speedFactorRunRight

Set speed factor running right.

  • Full name: playerInputMove.speedFactorRunRight
  • Type: float
  • Default Value: 1
  • Restriction: At least 0
  • Example (*.deeclass)
    <float name='playerInputMove.speedFactorRunRight'>6</float>

Events

This behavior has no events.

Behavior Tree Actions

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

playerInputMove.set

Set one or more player input move parameters.

ParameterValueDescription
resetempty string, analogReset player input move. If analog is set only resets analog values
locomotion.typenatural, fps, vehicle

Locomotion type:

TypeDescription
naturalDefault 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. Interferes with ECBehaviorPlayerInputTurn since both behaviors modify the locomotion turning value.
fpsConfiguration 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. Interferes with ECBehaviorPlayerInputTurn since both behaviors modify the locomotion turning value.
vehicleConfiguration useful for vehicle type actors like tanks which move into the direction their body is oriented while allowing to freely look around. Does not interfere with ECBehaviorPlayerInputTurn since this behavior does not modify the locomotion turning value.
forwardtrue, falseMove forward key pressed
forward.toggle Toggle move forward key pressed
backwardtrue, falseMove backward key pressed
backward.toggle Toggle move backward key pressed
lefttrue, falseMove left key pressed
left.toggle Toggle move left key pressed
righttrue, falseMove right key pressed
right.toggle Toggle move right key pressed
analog.forwardBackwardfloat, eventParam, -eventParamAnalog move forward/backward value
analog.forwardBackward.sticky, eventParam, -eventParamfloatSticky analog move forward/backward value
analog.leftRightfloat, eventParam, -eventParamAnalog move left/right value
analog.leftRight.stickyfloat, eventParam, -eventParamSticky analog move left/right value
canMovetrue, falseCan move
canMove.toggle Toggle can move
runtrue, falseRun key pressed
run.toggle Toggle run key pressed
speed.walkfloatWalk speed in m/s
speed.walk.forwardfloatWalk forward speed multiplicator
speed.walk.backwardfloatWalk backward speed multiplicator
speed.walk.leftfloatWalk left speed multiplicator
speed.walk.rightfloatWalk right speed multiplicator
speed.runfloatRun speed in m/s
speed.run.forwardfloatRun forward speed multiplicator
speed.run.backwardfloatRun backward speed multiplicator
speed.run.leftfloatRun left speed multiplicator
speed.run.rightfloatRun right speed multiplicator
moving.directionfloatMoving direction in the range from -180 to 180 degrees
moving.speedfloatMoving speed in m/s

This is an example of using this action:

<action name='playerInputMove.set'>
  <parameter name='forward'>true</parameter>
</action>

playerInputMove.check

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).

ParameterValueDescription
locomotion.typenatural, fps, vehicleLocomtion type matches value
locomotion.type.notnatural, fps, vehicleLocomtion type does not match value
forwardtrue, falseMove forward key pressed
backwardtrue, falseMove backward key pressed
lefttrue, falseMove left key pressed
righttrue, falseMove right key pressed
analog.forwardBackward.lessfloatAnalog move forward/backward value is less than value
analog.forwardBackward.greaterfloatAnalog move forward/backward value is greater than value
analog.forwardBackward.sticky.lessfloatSticky analog move forward/backward value is less than value
analog.forwardBackward.sticky.greaterfloatSticky analog move forward/backward value is greater than value
analog.leftRight.lessfloatAnalog move left/right value is less than value
analog.leftRight.greaterfloatAnalog move left/right value is greater than value
analog.leftRight.sticky.lessfloatSticky analog move left/right value is less than value
analog.leftRight.sticky.greaterfloatSticky analog move left/right value is greater than value
canMovetrue, falseCan move
movingtrue, falsePlayer is moving meaning canMove is true and at least one movement key is pressed
runtrue, falseRun key pressed
speed.walk.lessfloatWalk speed is less than float value m/s
speed.walk.greaterfloatWalk speed is greater than float value m/s
speed.walk.forward.lessfloatWalk forward multiplicator is less than float value m/s
speed.walk.forward.greaterfloatWalk forward multiplicator is greater than float value m/s
speed.walk.backward.lessfloatWalk backward multiplicator is less than float value m/s
speed.walk.backward.greaterfloatWalk backward multiplicator is greater than float value m/s
speed.walk.left.lessfloatWalk left multiplicator is less than float value m/s
speed.walk.left.greaterfloatWalk left multiplicator is greater than float value m/s
speed.walk.right.lessfloatWalk right multiplicator is less than float value m/s
speed.run.right.greaterfloatRun right multiplicator is greater than float value m/s
speed.run.lessfloatRun speed is less than float value m/s
speed.run.greaterfloatRun speed is greater than float value m/s
speed.run.forward.lessfloatRun forward multiplicator is less than float value m/s
speed.run.forward.greaterfloatRun forward multiplicator is greater than float value m/s
speed.run.backward.lessfloatRun backward multiplicator is less than float value m/s
speed.run.backward.greaterfloatRun backward multiplicator is greater than float value m/s
speed.run.left.lessfloatRun left multiplicator is less than float value m/s
speed.run.left.greaterfloatRun left multiplicator is greater than float value m/s
speed.run.right.lessfloatRun right multiplicator is less than float value m/s
speed.run.right.greaterfloatRun right multiplicator is greater than float value m/s
moving.directionfloatMoving direction in the range from -180 to 180 degrees. Requires moving.direction.less or moving.direction.greater to be set
moving.direction.lessfloatDifference between moving.direction and moving direction is less than degree value
moving.direction.greaterfloatDifference between moving.direction and moving direction is greater than degree value
moving.speed.lessfloatMoving speed is less than float value m/s
moving.speed.greaterfloatMoving 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>

Behavior Tree Conditions

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

playerInputMove.check

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.

ParameterValueDescription
playerInputMove.locomotion.typenatural, fps, vehicleLocomtion type matches value
playerInputMove.locomotion.type.notnatural, fps, vehicleLocomtion type does not match value
playerInputMove.forwardtrue, falseMove forward key pressed
playerInputMove.backwardtrue, falseMove backward key pressed
playerInputMove.lefttrue, falseMove left key pressed
playerInputMove.righttrue, falseMove right key pressed
playerInputMove.analog.forwardBackward.lessfloatAnalog move forward/backward value is less than value
playerInputMove.analog.forwardBackward.greaterfloatAnalog move forward/backward value is greater than value
playerInputMove.analog.forwardBackward.sticky.lessfloatSticky analog move forward/backward value is less than value
playerInputMove.analog.forwardBackward.sticky.greaterfloatSticky analog move forward/backward value is greater than value
playerInputMove.analog.leftRight.lessfloatAnalog move left/right value is less than value
playerInputMove.analog.leftRight.greaterfloatAnalog move left/right value is greater than value
playerInputMove.analog.leftRight.sticky.lessfloatSticky analog move left/right value is less than value
playerInputMove.analog.leftRight.sticky.greaterfloatSticky analog move left/right value is greater than value
playerInputMove.canMovetrue, falseCan move
playerInputMove.movingtrue, falsePlayer is moving meaning canMove is true and at least one movement key is pressed
playerInputMove.runtrue, falseRun key pressed
playerInputMove.speed.walk.lessfloatWalk speed is less than float value m/s
playerInputMove.speed.walk.greaterfloatWalk speed is greater than float value m/s
playerInputMove.speed.walk.forward.lessfloatWalk forward multiplicator is less than float value m/s
playerInputMove.speed.walk.forward.greaterfloatWalk forward multiplicator is greater than float value m/s
playerInputMove.speed.walk.backward.lessfloatWalk backward multiplicator is less than float value m/s
playerInputMove.speed.walk.backward.greaterfloatWalk backward multiplicator is greater than float value m/s
playerInputMove.speed.walk.left.lessfloatWalk left multiplicator is less than float value m/s
playerInputMove.speed.walk.left.greaterfloatWalk left multiplicator is greater than float value m/s
playerInputMove.speed.walk.right.lessfloatWalk right multiplicator is less than float value m/s
playerInputMove.speed.run.right.greaterfloatRun right multiplicator is greater than float value m/s
playerInputMove.speed.run.lessfloatRun speed is less than float value m/s
playerInputMove.speed.run.greaterfloatRun speed is greater than float value m/s
playerInputMove.speed.run.forward.lessfloatRun forward multiplicator is less than float value m/s
playerInputMove.speed.run.forward.greaterfloatRun forward multiplicator is greater than float value m/s
playerInputMove.speed.run.backward.lessfloatRun backward multiplicator is less than float value m/s
playerInputMove.speed.run.backward.greaterfloatRun backward multiplicator is greater than float value m/s
playerInputMove.speed.run.left.lessfloatRun left multiplicator is less than float value m/s
playerInputMove.speed.run.left.greaterfloatRun left multiplicator is greater than float value m/s
playerInputMove.speed.run.right.lessfloatRun right multiplicator is less than float value m/s
playerInputMove.speed.run.right.greaterfloatRun right multiplicator is greater than float value m/s
playerInputMove.moving.directionfloatMoving direction in the range from -180 to 180 degrees. Requires moving.direction.less or moving.direction.greater to be set
playerInputMove.moving.direction.lessfloatDifference between moving.direction and moving direction is less than degree value
playerInputMove.moving.direction.greaterfloatDifference between moving.direction and moving direction is greater than degree value
playerInputMove.moving.speed.lessfloatMoving speed is less than float value m/s
playerInputMove.moving.speed.greaterfloatMoving 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>

State Machine Actions

State Machine Conditions

State Machine Events

This behavior send no events to state machine.

Required Behaviors

This behavior requires no other behaviors.

Optional Behaviors

Persistency

This behavior does not required element class to be persistable (setPersistable).

API Documentation

ECBehaviorPlayerInputMove.

Since DragonScript Module Version 1.0

Use Cases

  • Track player moving input and apply it to locomotion.

Element Class Example

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

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='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>

Live Examples

You could leave a comment if you were logged in.
dragengine/modules/dragonscript/bahevior_playerinputmove.1746665503.txt.gz · Last modified: 2025/05/08 00:51 by dragonlord