Start Page » DragonScript Scripting Language » Abstraction Layers: How you want to build your Game » Behavior Elements » ECBehaviorVRHandLocomotion
This behavior is designed to be used with ECBehaviorVRHand for which isUsingHandInteraction()
returns true.
Using hands only (or hand interaction) controllers there is no way to use sticks to move or turn the actor. This behavior simulates stick type movement by tracking hand position. The user begins moving and turning by looking at his hand and touching an application defined finger to the thumb, typically the middle finger. The index is usually a bad choice since VR runtimes tend to intercept this touch event for special system handling. The hand location relative to the HMD at the time of touching is stored as origin. While still touching the thumb the user can then move the hand left, right, forward, backwards, up and down. This is like if the user is moving the tip of an imaginary stick. Each movement direction is assigned a Command
of this the analog value is set from the distance from the origin. Left/right is the X axis, up/down the Y axis and forward/backward the Z axis. Furthermore button press events are simulated on the same commands if the value is larger than 75% away from the origin. There is a dead-zone near the stored origin to avoid unintentional turning or moving. Furthermore the input is not linear from the dead zone border to the input range. This allows for easier input of small turning and movement while still being able to turn and move faster near the range.
This behavior can be added twice to an element to add support for left and right hand. Use the behavior identifier to tell them apart.
This behavior adds no element class properties.
This behavior adds these behavior tree actions if behavior tree is present. If behavior has non-empty identifier replace vrHandLocomotion
with vrHandLocomotion(id)
.
Set VR hand locomotion parameters.
Parameter | Value | Description | ||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
enabled | true , false | Enable hand locomotion tracking. | ||||||||||||||||||||||||
deadzone | float | Deadzone as percentage of the range. User has to move hand further from the center than the range*deadzone distance to start locomotion tracking. Value is clamped to range from 0 to 1. | ||||||||||||||||||||||||
linearity | float | Set linearity of input. Value of 0 is linear input. Values up to 1 map larger input range to small movement. Values down to -1 map larger input range to larger movement. 0.25 is the default. Linearity is calculated like this:
|
||||||||||||||||||||||||
command.profile | string | Set commands to run using a profile name.
|
||||||||||||||||||||||||
command.x | string | Set named command for both positive and negative X axis or empty to clear | ||||||||||||||||||||||||
command.x.positive | string | Set named command for positive X axis or empty to clear | ||||||||||||||||||||||||
command.x.negative | string | Set named command for positive X axis or empty to clear | ||||||||||||||||||||||||
command.y | string | Set named command for both positive and negative Y axis or empty to clear | ||||||||||||||||||||||||
command.y.positive | string | Set named command for positive Y axis or empty to clear | ||||||||||||||||||||||||
command.y.negative | string | Set named command for positive Y axis or empty to clear | ||||||||||||||||||||||||
command.z | string | Set named command for both positive and negative Z axis or empty to clear | ||||||||||||||||||||||||
command.z.positive | string | Set named command for positive Z axis or empty to clear | ||||||||||||||||||||||||
command.z.negative | string | Set named command for positive Z axis or empty to clear |
This is an example of using this action:
<action name='vrHandLocomotion(right).set'> <parameter name='command.profile'>turn</parameter> </action>
Check one or more VR hand locomotion parameters. Action succeeds if all parameter value matches their respective VR hand locomotion parameter otherwise action fails. This action is typically used as first action in a sequence to run the sequence only if a VR hand locomotion parameter matches (or not).
Input values are in the range from -1 to 1. Deadzone is not included hence a value of 0 refers to any hand position inside the deadzone area. Positive X axis is to the right, positive Y axis up and positive Z axis forward.
Not set command matches empty string.
Parameter | Value | Description |
---|---|---|
enabled | true , false | Hand locomotion is enabled |
running | true , false | Hand tracking is running |
input.x.value.less | float | X axis input value is less than value (range -1 to 1) |
input.x.value.greater | float | X axis input value is greater than value (range -1 to 1) |
input.y.value.less | float | Y axis input value is less than value (range -1 to 1) |
input.y.value.greater | float | Y axis input value is greater than value (range -1 to 1) |
input.z.value.less | float | Z axis input value is less than value (range -1 to 1) |
input.z.value.greater | float | Z axis input value is greater than value (range -1 to 1) |
command.x.positive | string | Name of positive X axis command matches value |
command.x.positive.not | string | Name of positive X axis command matches not value |
command.x.negative | string | Name of negative X axis command matches value |
command.x.negative.not | string | Name of negative X axis command matches not value |
command.y.positive | string | Name of positive Y axis command matches value |
command.y.positive.not | string | Name of positive Y axis command matches not value |
command.y.negative | string | Name of negative Y axis command matches value |
command.y.negative.not | string | Name of negative Y axis command matches not value |
command.z.positive | string | Name of positive Z axis command matches value |
command.z.positive.not | string | Name of positive Z axis command matches not value |
command.z.negative | string | Name of negative Z axis command matches value |
command.z.negative.not | string | Name of negative Z axis command matches not 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:
<sequence> <action name='vrHandLocomotion(right).check'> <parameter name='running'>true</parameter> <parameter name='input.z.value.greater'>0.5</parameter> </action> <!-- actions here run only if VR hand locomotion is running and the user moved the hand at least 50% forward --> </sequence>
This behavior adds these behavior tree conditions if behavior tree is present. If behavior has non-empty identifier replace vrHandLocomotion
with vrHandLocomotion(id)
.
Check one or more VR hand point-at parameters. Conditions returns true if all parameter value match their respective VR hand point-at parameter. This condition is typically used to run an action or sequence of actions as long as VR hand point-at conditions are true.
Input values are in the range from -1 to 1. Deadzone is not included hence a value of 0 refers to any hand position inside the deadzone area. Positive X axis is to the right, positive Y axis up and positive Z axis forward.
Not set command matches empty string.
Parameter | Value | Description |
---|---|---|
vrHandLocomotion.enabled | true , false | Hand locomotion is enabled |
vrHandLocomotion.running | true , false | Hand tracking is running |
vrHandLocomotion.input.x.value.less | float | X axis input value is less than value (range -1 to 1) |
vrHandLocomotion.input.x.value.greater | float | X axis input value is greater than value (range -1 to 1) |
vrHandLocomotion.input.y.value.less | float | Y axis input value is less than value (range -1 to 1) |
vrHandLocomotion.input.y.value.greater | float | Y axis input value is greater than value (range -1 to 1) |
vrHandLocomotion.input.z.value.less | float | Z axis input value is less than value (range -1 to 1) |
vrHandLocomotion.input.z.value.greater | float | Z axis input value is greater than value (range -1 to 1) |
vrHandLocomotion.command.x.positive | string | Name of positive X axis command matches value |
vrHandLocomotion.command.x.positive.not | string | Name of positive X axis command matches not value |
vrHandLocomotion.command.x.negative | string | Name of negative X axis command matches value |
vrHandLocomotion.command.x.negative.not | string | Name of negative X axis command matches not value |
vrHandLocomotion.command.y.positive | string | Name of positive Y axis command matches value |
vrHandLocomotion.command.y.positive.not | string | Name of positive Y axis command matches not value |
vrHandLocomotion.command.y.negative | string | Name of negative Y axis command matches value |
vrHandLocomotion.command.y.negative.not | string | Name of negative Y axis command matches not value |
vrHandLocomotion.command.z.positive | string | Name of positive Z axis command matches value |
vrHandLocomotion.command.z.positive.not | string | Name of positive Z axis command matches not value |
vrHandLocomotion.command.z.negative | string | Name of negative Z axis command matches value |
vrHandLocomotion.command.z.negative.not | string | Name of negative Z axis command matches not value |
This is an example of using this condition:
<action name='myAction' id='doing something'> <parameter name='vrHandLocomotion(right).running'>true</parameter> <parameter name='vrHandLocomotion(right).input.z.value.greater'>0.5</parameter> <condition>vrHandLocomotion(right).check</condition> </action>
Same as Behavior Tree Actions.
Same as Behavior Tree Conditions.
This behavior sends these state machine events. If behavior has non-empty identifier replace vrHandLocomotion
with vrHandLocomotion(id)
.
VR hand locomotion has been enabled.
VR hand locomotion has been disabled.
Input tracking has been started.
Input tracking has been stopped.
This behavior does not require element class to be persistable (setPersistable).
Since DragonScript Module Version 1.28
The following example creates an element class with support for hand locomotion:
class MyElement extends BehaviorElementClass public var ECBehaviorPlayerControllable playerControllable public var ECBehaviorVRPlayspace vrPlayspace public var ECBehaviorVRHand vrHandRight public var ECBehaviorVRHand vrHandLeft public var ECBehaviorVRHandLocomotion vrRightHandLocomotion public var ECBehaviorVRHandLocomotion vrLeftHandLocomotion public func new() // Create player controllable playerControllable = ECBehaviorPlayerControllablenew(this) // Create playspace vrPlayspace = ECBehaviorVRPlayspace.new(this) // Create hand controllers. The InputDeviceType indicates what device type // to monitor. vrRightHand and vrLeftHand can exist only once vrHandRight = ECBehaviorVRHand.new(this, vrPlayspace, InputDeviceType.vrRightHand, "right") vrHandLeft = ECBehaviorVRHand.new(this, vrPlayspace, InputDeviceType.vrLeftHand, "left") // Create hand locomotion behavior for each hand vrRightHandLocomotion = ECBehaviorVRHandLocomotion.new(this, vrRightHand, playerControllable, "right") vrLeftHandLocomotion = ECBehaviorVRHandLocomotion.new(this, vrLeftHand, playerControllable, "left") end end
The BaseVRActorClass provides full VR support including ECBehaviorVRHandLocomotion for both hands.
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='ECBehaviorPlayerControllablenew'/> <behavior type='ECBehaviorVRPlayspace'/> <behavior type='ECBehaviorVRHand' id='right'/> <behavior type='ECBehaviorVRHand' id='left'/> <behavior type='ECBehaviorVRHandLocomotion' id='right'> <!-- required: use vr hand with id. --> <string name='vrHand'>right</string> <!-- optional: use BaseGameApp command manager. game can add more supported values. default is 'default' --> <string name='commandManager'>default</string> <!-- optional: add behavior trees. default adds all behavior trees. --> <list name='behaviorTrees'> <string/> <!-- add behavior with empty identifier --> <string>default</string> <!-- add behavior with 'default' identifier --> </list> <!-- optional: add state machines. default adds all state machines. --> <list name='stateMachines'> <string/> <!-- add behavior with empty identifier --> <string>default</string> <!-- add behavior with 'default' identifier --> </list> <!-- set element properties. omit property prefix if used inside behavior tag --> <string name='.name'>value</string> </behavior> <behavior type='ECBehaviorVRHandLocomotion' id='left'> ... </behavior> </elementClass>