{{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]] >> **ECBehaviorPlayerInputTurn**
* [[behaviors_use_cases|Behaviors Explained: By Use-Case]]
* [[behaviors_a_to_z|Behaviors Explained: From A to Z]]
====== 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) 30
====== 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.
^Parameter^Value^Description^
|reset| |Reset player input turn|
|left|''true'', ''false''|Left turn key pressed|
|left.toggle| |Toggle left turn key pressed|
|right|''true'', ''false''|Right turn key pressed|
|right.toggle| |Toggle right turn key pressed|
|speed|float|Turn speed in m/s|
|analog|float, ''eventParam'', ''-eventParam''|Add analog turn value in the range from -180 to 180 degrees|
|analog.sticky|float, ''eventParam'', ''-eventParam''|Set sticky analog turn value in the range from -180 to 180 degrees|
|canTurn|''true'', ''false''|Can turn|
|canTurn.toggle| |Toggle can turn|
This is an example of using this action:
true
===== playerInputTurn.update =====
Update player input turn.
^Parameter^Value^Description^
|locomotion| |Update locomotion applying calculateLookHorizontal() and calculateLookVertical() to [[behavior_locomotion|ECBehaviorLocomotion]].applyLookAround()|
This is an example of using this 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).
^Parameter^Value^Description^
|left|''true'', ''false''|Left turn key pressed|
|speed.less|float|Speed is less than float value m/s|
|speed.greater|float|Speed is greater than float value m/s|
|analog.less|float|Analog value is less than float value degrees|
|analog.greater|float|Analog value is greater than float value degrees|
|analog.sticky.less|float|Sticky analog value is less than float value degrees|
|analog.sticky.greater|float|Sticky analog value is greater than float value degrees|
|canTurn|''true'', ''false''|Can 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:
true
====== 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.
^Parameter^Value^Description^
|playerInputTurn.left|''true'', ''false''|Left turn key pressed|
|playerInputTurn.speed.less|float|Speed is less than float value m/s|
|playerInputTurn.speed.greater|float|Speed is greater than float value m/s|
|playerInputTurn.analog.less|float|Analog value is less than float value degrees|
|playerInputTurn.analog.greater|float|Analog value is greater than float value degrees|
|playerInputTurn.analog.sticky.less|float|Sticky analog value is less than float value degrees|
|playerInputTurn.analog.sticky.greater|float|Sticky analog value is greater than float value degrees|
|playerInputTurn.canTurn|''true'', ''false''|Can turn|
This is an example of using this condition:
true
playerInputTurn.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 send no events to state machine.
====== Required Behaviors ======
This behavior requires no other behaviors.
====== Optional Behaviors ======
* [[behavior_locomotion|ECBehaviorLocomotion]]: Update locomotion turning parameters.
* [[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 not required element class to be persistable (setPersistable).
====== API Documentation ======
#@LinkApiDocDEDS2_HTML~classDragengine_1_1Scenery_1_1ECBehaviorPlayerInputTurn.html,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:
second
second
Color 1
====== Live Examples ======
* [[https://github.com/LordOfDragons/deexamples|DEExamples Repository]]