User Tools

Site Tools


dragengine:modules:dragonscript:behavior_vrhandpointedat

This is an old revision of the document!


ECBehaviorVRHandPointedAt

Behavior element behavior adding support to track if VR hands point at element.

This behavior tracks if hand controllers are pointing at the element. If hand controllers start pointing at the element they are added to the list and listeners are notified. If the hand controllers stop pointing at the element they are removed from the list and listeners are notified. The behavior itself is passive. It requires to be triggered by the hand controllers elements. The ECBehaviorVRHandPointAt behavior provides this functionality.

Instance Counts

This behavior can be used only once on an element.

Element Class Properties

Element class properties have the prefix vrHandPointedAt. .

This behavior defines no element class properties.

Events

handStartsPointingAt

Hand starts pointing at element.

handStopsPointingAt

Hand stops pointing at element.

Behavior Tree Actions

This behavior adds these behavior tree actions if behavior tree is present.

vrHandPointedAt.check

Check one or more vr hand pointed-at parameters. Action succeeds if all parameter value matches their respective vr hand pointed-at parameter otherwise action fails. This action is typically used as first action in a sequence to run the sequence only if a vr hand pointed-at parameter matches (or not).

ParameterValueDescription
countintegerCount of vr hands pointing at element equals integer value
count.notintegerCount of vr hands pointing at element does not equal integer value
count.lessintegerCount of vr hands pointing at element is less than integer value
count.greaterintegerCount of vr hands pointing at element is greater than integer value
playertrue, falsePlayer is pointing at element

This is an example of using this action:

<sequence>
  <action name='vrHandPointedAt.check'>
    <parameter name='player'>true</parameter>
  </action>
  <!-- actions here run only if player is pointing at element -->
</sequence>

Behavior Tree Conditions

This behavior adds these behavior tree conditions if behavior tree is present.

vrHandPointedAt.check

Check one or more vr hand pointed-at parameters. Conditions returns true if all parameter value match their respective vr hand pointed-at parameter. This condition is typically used to run an action or sequence of actions as long as vr hand pointed-at conditions are true.

ParameterValueDescription
vrHandPointedAt.countintegerCount of vr hands pointing at element equals integer value
vrHandPointedAt.count.notintegerCount of vr hands pointing at element does not equal integer value
vrHandPointedAt.count.lessintegerCount of vr hands pointing at element is less than integer value
vrHandPointedAt.count.greaterintegerCount of vr hands pointing at element is greater than integer value
vrHandPointedAt.playertrue, falsePlayer is pointing at element

This is an example of using this condition:

<action name='myAction' id='doing something'>
  <parameter name='vrHandPointedAt.player'>true</parameter>
  <condition>vrHandPointedAt.check</condition>
</action>

Required Behaviors

This behavior does not required other behaviors to be present.

Optional Behaviors

Persistency

This behavior does support element class to be persistable (setPersistable).

API Documentation

ECBehaviorVRHandPointedAt.

Since DragonScript Module Version 1.7

Use Cases

  • Show outline and interact prompts if player points at object.
  • For NPCs to react to player (or other actors) pointing at them (for example looking back at player).
  • Show target information if player aims at objects.

Element Class Example

class ExampleElementClass extends BehaviorElementClass
   public var ECBehaviorVRHandPointedAt vrHandPointedAt
   
   public func new() super("ExampleElement")
     // Add pointed at behavior. By itself this does nothing yet. Add listeners to the
     // behavior to react to pointing-at changes. This is typically done by other
     // behaviors to provide their functionality
     vrHandPointedAt = ECBehaviorVRHandPointedAt.new(this)
   end
end

Behavior Factory

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='ECBehaviorVRHandPointedAt'>
    <!-- optional: use behavior tree with id instead of empty string -->
    <string name='behaviorTree'>second</string>
 
    <!-- optional: use state machine with id instead of empty string -->
    <string name='stateMachine'>second</string>
 
    <!-- set element properties. omit property prefix if used inside behavior tag -->
    <string name='.name'>value</string>
  </behavior>
</elementClass>

Live Examples

You could leave a comment if you were logged in.
dragengine/modules/dragonscript/behavior_vrhandpointedat.1746222707.txt.gz · Last modified: 2025/05/02 21:51 by dragonlord