{{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]] >> **ECBehaviorPlayerInputLook**
* [[behaviors_use_cases|Behaviors Explained: By Use-Case]]
* [[behaviors_a_to_z|Behaviors Explained: From A to Z]]
====== ECBehaviorPlayerInputLook ======
Behavior element behavior adding looking around player input.
Keeps track of looking around player input and applies them to actor locomotion.
===== Digital Input =====
Supports digital input by player for looking left-right and up-down using digital input devices like keyboard or game pad buttons. The setSpeedLookHorizontal() and setSpeedLookVertical() methods set the speed of looking while the input is enabled. The calculation of looking delta by digital input is this:
''delta = (+/-) speed * elapsedTime''.
Here ''+'' is if left input is enabled while ''-'' is used if right input is enabled. Using negative speed switches direction.
===== Analog Input =====
Supports analog input by player for looking left-right and up-down using analog input devices like mouse, game pad analog sticksothers. The analog input can be set directly from the input event (for example mouse move deltas). The setAnalogFactorLookHorizontal() and setAnalogFactorLookVertical() methods set the sensitivity of the input value transforming it into a value comparable to using digital input. The default value is ''0.01'' resulting in analog input suitable for first person navigation. Smaller values make analog input slower increasing accuracy pointing at specific locations while larger values make analog input faster. The same holds true for changing the digital input speed. The calculation of looking delta by analog input is this:
''delta = analogInput * analogFactor * speed''.
This calculation applies only to non-sticky input as this originates from mouse input devices only. Sticky inputs originating from game pads and similar used the elapsed time instead of analogFactor and thus are similar to digital input. Using negative factor switches direction. Using negative factor and speed keeps the direction unchanged.
====== Instance Counts ======
This behavior can be used only once on an element.
====== Element Class Properties ======
Element class properties have the prefix ''playerInputLook.'' .
===== speedLookHorizontal =====
Set look left right speed in degrees per second.
* Full name: ''playerInputLook.speedLookHorizontal''
* Type: float
* Default Value: 45
* Restriction: At least 0
* Example (*.deeclass) 30
===== speedLookVertical =====
Set look up down speed in degrees per second.
* Full name: ''playerInputLook.speedLookVertical''
* Type: float
* Default Value: 45
* Restriction: At least 0
* Example (*.deeclass) 30
===== analogFactorLookHorizontal =====
Set analog Look left right factor relative to left right input speed.
* Full name: ''playerInputLook.analogFactorLookHorizontal''
* Type: float
* Default Value: 0.01
* Example (*.deeclass) 0.02
===== analogFactorLookVertical =====
Set analog Look up down factor relative to up down input speed.
* Full name: ''playerInputLook.analogFactorLookVertical''
* Type: float
* Default Value: 0.01
* Example (*.deeclass) 0.02
====== Events ======
This behavior has no events.
====== Behavior Tree Actions ======
This behavior adds these behavior tree actions if behavior tree is present.
===== playerInputLook.set =====
Set one or more player input look parameters.
^Parameter^Value^Description^
|reset| |Reset player input look|
|left|''true'', ''false''|Look left key pressed|
|left.toggle| |Toggle look left key pressed|
|right|''true'', ''false''|Look right key pressed|
|right.toggle| |Toggle look right key pressed|
|up|''true'', ''false''|Look up key pressed|
|up.toggle| |Toggle look up key pressed|
|down|''true'', ''false''|Look down key pressed|
|down.toggle| |Toggle look down key pressed|
|speed.horizontal|float|Horizontal looking speed in m/s|
|analog.horizontal|float, ''eventParam'', ''-eventParam''|Add analog horizontal looking in the range from -180 to 180 degrees|
|analog.horizontal.factor|float|Analog horizontal looking multiplicator|
|analog.horizontal.sticky|float, ''eventParam'', ''-eventParam''|Set sticky analog horizontal looking in the range from -180 to 180 degrees|
|speed.vertical|float|Vertical looking speed in m/s|
|analog.vertical|float, ''eventParam'', ''-eventParam''|Add analog vertical looking in the range from -180 to 180 degrees|
|analog.vertical.factor|float|Analog vertical looking multiplicator|
|analog.vertical.sticky|float, ''eventParam'', ''-eventParam''|Set sticky analog vertical looking in the range from -180 to 180 degrees|
This is an example of using this action:
true
===== playerInputLook.update =====
Update player input look.
^Parameter^Value^Description^
|locomotion| |Update locomotion applying calculateLookHorizontal() and calculateLookVertical() to [[behavior_locomotion|ECBehaviorLocomotion]].applyLookAround()|
This is an example of using this action:
===== playerInputLook.check =====
Check one or more player input look parameters. Action succeeds if all parameter value matches their respective player input look parameter otherwise action fails. This action is typically used as first action in a sequence to run the sequence only if a player input look parameter matches (or not).
^Parameter^Value^Description^
|left|''true'', ''false''|Look left key pressed|
|right|''true'', ''false''|Look right key pressed|
|up|''true'', ''false''|Look up key pressed|
|down|''true'', ''false''|Look down key pressed|
|speed.horizontal.less|float|Horizontal speed is less than float value m/s|
|speed.horizontal.greater|float|Horizontal speed is greater than float value m/s|
|analog.horizontal.less|float|Analog horizontal value is less than value|
|analog.horizontal.greater|float|Analog horizontal value is greater than value|
|analog.horizontal.sticky.less|float|Sticky analog horizontal value is less than value|
|analog.horizontal.sticky.greater|float|Sticky analog horizontal value is greater than value|
|speed.vertical.less|float|Vertical speed is less than float value m/s|
|speed.vertical.greater|float|Vertical speed is greater than float value m/s|
|analog.vertical.less|float|Analog vertical value is less than value|
|analog.vertical.greater|float|Analog vertical value is greater than value|
|analog.vertical.sticky.less|float|Sticky analog vertical value is less than value|
|analog.vertical.sticky.greater|float|Sticky analog vertical value is greater than value|
|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.
===== playerInputLook.check =====
Check one or more player input look parameters. Conditions returns true if all parameter value match their respective player input look parameter. This condition is typically used to run an action or sequence of actions as long as player input look conditions are true.
^Parameter^Value^Description^
|playerInputLook.left|''true'', ''false''|Look left key pressed|
|playerInputLook.right|''true'', ''false''|Look right key pressed|
|playerInputLook.up|''true'', ''false''|Look up key pressed|
|playerInputLook.down|''true'', ''false''|Look down key pressed|
|playerInputLook.speed.horizontal.less|float|Horizontal speed is less than float value m/s|
|playerInputLook.speed.horizontal.greater|float|Horizontal speed is greater than float value m/s|
|playerInputLook.analog.horizontal.less|float|Analog horizontal value is less than value|
|playerInputLook.analog.horizontal.greater|float|Analog horizontal value is greater than value|
|playerInputLook.analog.horizontal.sticky.less|float|Sticky analog horizontal value is less than value|
|playerInputLook.analog.horizontal.sticky.greater|float|Sticky analog horizontal value is greater than value|
|playerInputLook.speed.vertical.less|float|Vertical speed is less than float value m/s|
|playerInputLook.speed.vertical.greater|float|Vertical speed is greater than float value m/s|
|playerInputLook.analog.vertical.less|float|Analog vertical value is less than value|
|playerInputLook.analog.vertical.greater|float|Analog vertical value is greater than value|
|playerInputLook.analog.vertical.sticky.less|float|Sticky analog vertical value is less than value|
|playerInputLook.analog.vertical.sticky.greater|float|Sticky analog vertical value is greater than value|
|playerInputLook.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 condition:
true
playerInputLook.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]]: Apply looking around on locomotion instance
* [[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_1ECBehaviorPlayerInputLook.html,ECBehaviorPlayerInputLook~@#.
Since DragonScript Module Version ''1.0''
====== Use Cases ======
* Track looking around player input and apply it to locomotion.
====== Element Class Example ======
This example defines an element which tracks player looking around input.
class MyElement extends BehaviorElementClass
public var ECBehaviorPlayerInputLook playerInputLook
func new()
ECBehaviorPlayerInputLook.new(this)
end
end
====== Behavior Factory ======
Using element class supporting adding behaviors the behavior can be added like this:
second
second
30
====== Live Examples ======
* [[https://github.com/LordOfDragons/deexamples|DEExamples Repository]]