This is an old revision of the document!
Start Page » DragonScript Scripting Language » Behavior Elements: Quick and Easy Development » 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.
<string name='vrHandLaserPointer(right).controllerLength'>length</string>
Name of particle emitter controller to update with laserpointer intensity or empty string if not used.
<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.
<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.
<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.
<string name='vrHandLaserPointer(right).controllerBlue'>blue</string>
Length in meters of laser pointer.
<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.
<float name='vrHandLaserPointer(right).intensity'>0.8</float>
Color of laser pointer.
<color name='vrHandLaserPointer(right).color' r='1' g='1' b='0'/>
This behavior does not support optional behaviors.
Saves these parameters:
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.