Start Page » DragonScript Scripting Language » Behavior Elements: Quick and Easy Development » ECBehaviorPlayerInputLook
Behavior element behavior adding looking around player input.
Keeps track of looking around player input and applies them to actor locomotion.
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.
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.
This behavior can be used only once on an element.
Element class properties have the prefix playerInputLook.
.
Set look left right speed in degrees per second.
playerInputLook.speedLookHorizontal
<float name='playerInputLook.speedLookHorizontal'>30</float>
Set look up down speed in degrees per second.
playerInputLook.speedLookVertical
<float name='playerInputLook.speedLookVertical'>30</float>
Set analog Look left right factor relative to left right input speed.
playerInputLook.analogFactorLookHorizontal
<float name='playerInputLook.analogFactorLookHorizontal'>0.02</float>
Set analog Look up down factor relative to up down input speed.
playerInputLook.analogFactorLookVertical
<float name='playerInputLook.analogFactorLookVertical'>0.02</float>
This behavior has no events.
This behavior requires no other behaviors.
This behavior does not required element class to be persistable (setPersistable).
Since DragonScript Module Version 1.0
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
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='ECBehaviorPlayerInputLook'> <!-- set element properties. omit property prefix if used inside behavior tag --> <string name='.speedLookHorizontal'>30</string> </behavior> </elementClass>