Start Page » DragonScript Scripting Language » Abstraction Layers: How you want to build your Game » Behavior Elements » ECBehaviorVRHandLaserPointer
Behavior element behavior adding VR Hand Controller Laser Pointer support to actor.
VR Hand Controllers often use a laser pointer type interaction.
This behavior adds a particle emitter representing the laser pointer. The behavior attaches itself to a ECBehaviorVRHandPointAt. The enable casting of the particle emitter is linked to the enabled state of ECBehaviorVRHandPointAt.
Named controllers can be used to set typically laserpointer parameters at runtime if the named controllers exist. The following named controllers are supported:
Additional named controllers can be added if required. The default particle emitter used is /shareddata/particles/laserpointer/laserpointer.depemit. This particle emitter defines the controller ranges like this:
The default particle emitter is set to use custom collision response. This behavior implements the response to make the beam stop at the first hit obstacle. The collision filter from ECBehaviorVRHandPointAt is copied to the particle emitter to ensure the results are comparable.
The particle emitter is aligned with the test direction.
This behavior can be added twice to an element to add support for left and right hand controller. Use the behavior identifier to tell them apart.
Element class properties have the prefix vrHandLaserPointer. or vrHandLaserPointer(id). if id is not empty.
This behavior adds a child ECBehaviorParticleEmitter to the element class to show the laser pointer in the game world. The child behavior has the identifier vrHandLaserPointer or vrHandLaserPointer(id). The child behavior has the element class property prefix vrHandLaserPointer.particleEmitter. or vrHandLaserPointer(id).particleEmitter. .
Hence to set for example the particle emitter of the right hand use the element class property vrHandLaserPointer(right).particleEmitter.path .
Name of particle emitter controller to update with laserpointer length or empty string if not used.
vrHandLaserPointer.controllerLength or vrHandLaserPointer(id).controllerLengthlength<string name='vrHandLaserPointer(right).controllerLength'>length</string>
Name of particle emitter controller to update with laserpointer intensity or empty string if not used.
vrHandLaserPointer.controllerIntensity or vrHandLaserPointer(id).controllerIntensityintensity<string name='vrHandLaserPointer(right).controllerIntensity'>intensity</string>
Name of particle emitter controller to update with laserpointer red color component or empty string if not used.
vrHandLaserPointer.controllerRed or vrHandLaserPointer(id).controllerRedred<string name='vrHandLaserPointer(right).controllerRed'>red</string>
Name of particle emitter controller to update with laserpointer green color component or empty string if not used.
vrHandLaserPointer.controllerGreen or vrHandLaserPointer(id).controllerGreengreen<string name='vrHandLaserPointer(right).controllerGreen'>green</string>
Name of particle emitter controller to update with laserpointer blue color component or empty string if not used.
vrHandLaserPointer.controllerBlue or vrHandLaserPointer(id).controllerBlueblue<string name='vrHandLaserPointer(right).controllerBlue'>blue</string>
Length in meters of laser pointer.
vrHandLaserPointer.length or vrHandLaserPointer(id).length10<float name='vrHandLaserPointer(right).length'>15</float>
Intensity of laser pointer. The actual intensity used depends on the particle emitter. Usually particle emitters use camera adapted intensity which maps an intensity of 1 to the camera upper intensity.
vrHandLaserPointer.intensity or vrHandLaserPointer(id).intensity0.4<float name='vrHandLaserPointer(right).intensity'>0.8</float>
Color of laser pointer.
vrHandLaserPointer.color or vrHandLaserPointer(id).color(0, 1, 1)<color name='vrHandLaserPointer(right).color' r='1' g='1' b='0'/>
This behavior has no events.
This behavior adds these behavior tree actions if behavior tree is present. If behavior has non-empty identifier replace vrHandLaserPointer with vrHandLaserPointer(id).
Set one or more VR hand laser pointer parameters.
| Parameter | Value | Description |
|---|---|---|
| length | float | Length of beam in meters |
| intensity | float | Intensity of beam |
| color | color | Color of beam |
This is an example of using this action:
<action name='vrHandLaserPointer.set'> <parameter name='color'>1 0 0</parameter> </action>
Check one or more VR hand laser pointer parameters. Action succeeds if all parameter value matches their respective VR hand laser pointer parameter otherwise action fails. This action is typically used as first action in a sequence to run the sequence only if a VR hand laser pointer parameter matches (or not).
| Parameter | Value | Description |
|---|---|---|
| length.less | float | Length of beam is less than value meters |
| length.greater | float | Length of beam is greater than value meters |
| intensity.less | float | Intensity of beam is less than value meters |
| intensity.greater | float | Intensity of beam is greater than value meters |
| color.red.less | float | Red color of beam is less than value |
| color.red.greater | float | Red color of beam is greater than value |
| color.green.less | float | Green color of beam is less than value |
| color.green.greater | float | Green color of beam is greater than value |
| color.blue.less | float | Blue color of beam is less than value |
| color.blue.greater | float | Blue color of beam 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:
<sequence> <action name='vrHandLaserPointer.check'> <parameter name='intensity.less'>0.5</parameter> </action> <!-- actions here run only if intensity of beam is less than 50% --> </sequence>
This behavior adds these behavior tree conditions if behavior tree is present. If behavior has non-empty identifier replace vrHandLaserPointer with vrHandLaserPointer(id).
Check one or more VR hand laser pointer parameters. Conditions returns true if all parameter value match their respective VR hand laser pointer parameter. This condition is typically used to run an action or sequence of actions as long as VR hand laser pointer conditions are true.
| Parameter | Value | Description |
|---|---|---|
| vrHandLaserPointer.length.less | float | Length of beam is less than value meters |
| vrHandLaserPointer.length.greater | float | Length of beam is greater than value meters |
| vrHandLaserPointer.intensity.less | float | Intensity of beam is less than value meters |
| vrHandLaserPointer.intensity.greater | float | Intensity of beam is greater than value meters |
| vrHandLaserPointer.color.red.less | float | Red color of beam is less than value |
| vrHandLaserPointer.color.red.greater | float | Red color of beam is greater than value |
| vrHandLaserPointer.color.green.less | float | Green color of beam is less than value |
| vrHandLaserPointer.color.green.greater | float | Green color of beam is greater than value |
| vrHandLaserPointer.color.blue.less | float | Blue color of beam is less than value |
| vrHandLaserPointer.color.blue.greater | float | Blue color of beam is greater than value |
This is an example of using this condition:
<action name='myAction' id='doing something'> <parameter name='vrHandLaserPointer.intensity.less'>0.5</parameter> <condition>vrHandLaserPointer.check</condition> </action>
Same as Behavior Tree Actions.
Same as Behavior Tree Conditions.
This behavior sends no state machine events.
This behavior does support element class to be persistable (setPersistable).
Since DragonScript Module Version 1.7
The following example creates an element class with laser pointer support.
class MyElement extends BehaviorElementClass
public var ECBehaviorVRPlayspace vrPlayspace
public var ECBehaviorVRHand vrHandRight
public var ECBehaviorVRHand vrHandLeft
public var ECBehaviorVRHandPointAt vrRightHandPointAt
public var ECBehaviorVRHandPointAt vrLeftHandPointAt
public var ECBehaviorVRHandLaserPointer vrRightHandLaserPointer
public var ECBehaviorVRHandLaserPointer vrLeftHandLaserPointer
public func new()
// 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 point at behavior for each hand. By default the test direction
// is along the controller Z axis. For common controllers this points
// along the handle direction which is like holding a sword or similar
vrRightHandPointAt = ECBehaviorVRHandPointAt.new(this, vrRightHand, "right")
vrLeftHandPointAt = ECBehaviorVRHandPointAt.new(this, vrLeftHand, "left")
// If you have a ECBehaviorCollider in your element class it is a good idea
// to ignore this collider. This avoids the point hitting the player body
// or hands.
// vrRightHandPointAt.setIgnoreCollider(collider)
// vrLeftHandPointAt.setIgnoreCollider(collider)
// Add laser pointers. These are disabled by default. Enable them in
// actor actions for example when the player touches the track pad
// on his controller or whenever a specific actor action activates
vrRightHandLaserPointer = ECBehaviorVRHandLaserPointer.new(this, vrRightHandPointAt, "right")
vrLeftHandLaserPointer = ECBehaviorVRHandLaserPointer.new(this, vrLeftHandPointAt, "left")
end
end
The BaseVRActorClass provides full VR support including ECBehaviorVRHandLaserPointer 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='ECBehaviorVRPlayspace'/> <behavior type='ECBehaviorVRHand' id='right'/> <behavior type='ECBehaviorVRHand' id='left'/> <behavior type='ECBehaviorVRHandPointAt' id='right'> <string name='vrHand'>right</string> </behavior> <behavior type='ECBehaviorVRHandPointAt' id='left'> <string name='vrHand'>left</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> </behavior> <behavior type='ECBehaviorVRHandLaserPointer' id='right'> <!-- required: use vr hand point at with id --> <string name='vrHandPointAt'>right</string> <!-- set element properties. omit property prefix if used inside behavior tag --> <string name='.name'>value</string> </behavior> <behavior type='ECBehaviorVRHandLaserPointer' id='left'> <string name='vrHandPointAt'>left</string> </behavior> </elementClass>