User Tools

Site Tools


dragengine:modules:dragonscript:behavior_playerinputturn

ECBehaviorPlayerInputTurn

Behavior element behavior adding turning player input.

Keeps track of turning player input and applies them to actor locomotion.

This behavior is typically used for vehicle type actors.

Instance Counts

This behavior can be used only once on an element.

Element Class Properties

Element class properties have the prefix playerInputTurn. .

speedTurnHorizontal

Set turn left right speed in degrees per second.

  • Full name: playerInputTurn.speedTurnHorizontal
  • Type: float
  • Default Value: 45
  • Restriction: At least 0
  • Example (*.deeclass)
    <float name='playerInputTurn.speedTurnHorizontal'>30</float>

Events

This behavior has no events.

Behavior Tree Actions

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

playerInputTurn.set

Set one or more player input turn parameters.

ParameterValueDescription
reset Reset player input turn
lefttrue, falseLeft turn key pressed
left.toggle Toggle left turn key pressed
righttrue, falseRight turn key pressed
right.toggle Toggle right turn key pressed
speedfloatTurn speed in m/s
analogfloat, eventParam, -eventParamAdd analog turn value in the range from -180 to 180 degrees
analog.stickyfloat, eventParam, -eventParamSet sticky analog turn value in the range from -180 to 180 degrees
canTurntrue, falseCan turn
canTurn.toggle Toggle can turn

This is an example of using this action:

<action name='playerInputTurn.set'>
  <parameter name='left'>true</parameter>
</action>

playerInputTurn.update

Update player input turn.

ParameterValueDescription
locomotion Update locomotion applying calculateLookHorizontal() and calculateLookVertical() to ECBehaviorLocomotion.applyLookAround()

This is an example of using this action:

<action name='playerInputLook.update'>
  <parameter name='locomotion'/>
</action>

playerInputTurn.check

Check one or more player input turn parameters. Action succeeds if all parameter value matches their respective player input turn parameter otherwise action fails. This action is typically used as first action in a sequence to run the sequence only if a player input turn parameter matches (or not).

ParameterValueDescription
lefttrue, falseLeft turn key pressed
speed.lessfloatSpeed is less than float value m/s
speed.greaterfloatSpeed is greater than float value m/s
analog.lessfloatAnalog value is less than float value degrees
analog.greaterfloatAnalog value is greater than float value degrees
analog.sticky.lessfloatSticky analog value is less than float value degrees
analog.sticky.greaterfloatSticky analog value is greater than float value degrees
canTurntrue, falseCan turn
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='playerInputTurn.check'>
    <parameter name='left'>true</parameter>
  </action>
  <!-- actions here run only if left turn key is pressed -->
</sequence>

Behavior Tree Conditions

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

playerInputTurn.check

Check one or more player input turn parameters. Conditions returns true if all parameter value match their respective player input turn parameter. This condition is typically used to run an action or sequence of actions as long as player input turn conditions are true.

ParameterValueDescription
playerInputTurn.lefttrue, falseLeft turn key pressed
playerInputTurn.speed.lessfloatSpeed is less than float value m/s
playerInputTurn.speed.greaterfloatSpeed is greater than float value m/s
playerInputTurn.analog.lessfloatAnalog value is less than float value degrees
playerInputTurn.analog.greaterfloatAnalog value is greater than float value degrees
playerInputTurn.analog.sticky.lessfloatSticky analog value is less than float value degrees
playerInputTurn.analog.sticky.greaterfloatSticky analog value is greater than float value degrees
playerInputTurn.canTurntrue, falseCan turn

This is an example of using this condition:

<action name='myAction' id='doing something'>
  <parameter name='playerInputTurn.left'>true</parameter>
  <condition>playerInputTurn.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

ECBehaviorPlayerInputTurn.

Since DragonScript Module Version 1.0

Use Cases

  • Track player turning input and apply it to locomotion.

Element Class Example

This example defines an element which tracks player turning input.

class MyElement extends BehaviorElementClass
  public var ECBehaviorPlayerInputTurn playerInputTurn
  func new()
    playerInputTurn = ECBehaviorPlayerInputTurn.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='ECBehaviorPlayerInputTurn'>
    <!-- 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/behavior_playerinputturn.txt · Last modified: 2025/05/12 15:39 by dragonlord