{{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.
====== Required Behaviors ======
This behavior requires no other behaviors.
====== Optional Behaviors ======
* [[behavior_locomotion|ECBehaviorLocomotion]]: Apply looking around on locomotion instance
====== 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:
30
====== Live Examples ======
* [[https://github.com/LordOfDragons/deexamples|DEExamples Repository]]