User Tools

Site Tools


dragengine:modules:dragonscript:behavior_grabber

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
dragengine:modules:dragonscript:behavior_grabber [2022/02/05 18:36] – created dragonlorddragengine:modules:dragonscript:behavior_grabber [2025/03/13 17:13] (current) dragonlord
Line 1: Line 1:
 {{tag>dragonscript behavior}} {{tag>dragonscript behavior}}
 <WRAP youarehere> <WRAP youarehere>
-[[:start|Start Page]] >> [[main|DragonScript Scripting Language]] >> [[abstractions#behavior_elementsquick_and_easy_development|Behavior Elements: Quick and Easy Development]] >> **ECBehaviorGrabber**+[[:start|Start Page]] >> [[main|DragonScript Scripting Language]] >> [[dragengine:modules:dragonscript:abstractions|Abstraction Layers: How you want to build your Game]] >> [[dragengine:modules:dragonscript:behavior_elements|Behavior Elements]] >> **ECBehaviorGrabber**
 </WRAP> </WRAP>
  
Line 16: Line 16:
  
 To detect grab spots a touch sensor is added with a default sphere shape. By default the touch sensor is disabled and has to be enabled if the game logic allows grabbing. The collision filter category is set to BaseGameApp.CollisionFilterBit.trigger and the collision filter mask is set to BaseGameApp.CollisionFilterBit.dynamic. To detect grab spots a touch sensor is added with a default sphere shape. By default the touch sensor is disabled and has to be enabled if the game logic allows grabbing. The collision filter category is set to BaseGameApp.CollisionFilterBit.trigger and the collision filter mask is set to BaseGameApp.CollisionFilterBit.dynamic.
- 
-Element class properties have the prefix "grabber{(id)}.". 
- 
 ====== Instance Counts ====== ====== Instance Counts ======
  
Line 25: Line 22:
 ====== Element Class Properties ====== ====== Element Class Properties ======
  
-Element class properties have the prefix **vrHandPointAt.** or **vrHandPointAt(id).** if id is not empty.+Element class properties have the prefix ''grabber.'' or ''grabber(id).'' if id is not empty.
  
 ===== shape ===== ===== shape =====
 Shape of collider used to detect grab spots. Shape of collider used to detect grab spots.
-  * Full name: "grabber.shapeor "grabber(id).shape" +  * Full name: ''grabber.shape'' or ''grabber(id).shape'' 
-  * Type: string (shape list encoding)+  * Type: string (shape format). See "Shape List Encoding" in CodecPropertyString.
   * Default Value: empty string   * Default Value: empty string
   * Example (*.deeclass): <code xml><string name='grabber(right).shape'>box:extends,0.1,0.1,0.1</string></code>   * Example (*.deeclass): <code xml><string name='grabber(right).shape'>box:extends,0.1,0.1,0.1</string></code>
  
-===== attach.position =====+===== position =====
 Attach position relative to parent element or bone. Attach position relative to parent element or bone.
-  * Full name: "grabber.attach.positionor "grabber(id).attach.position" +  * Full name: ''grabber.position'' or ''grabber(id).position'' 
-  * Type: 3-component vector +  * Type: 3-component float vector 
-  * Default Value: (0, 0, 0) +  * Default Value: ''(0, 0, 0)'' 
-  * Example (*.deeclass): <code xml><vector name='grabber(right).attach.position' x='0' y='0' z='0.1'/></code>+  * Example (*.deeclass): <code xml><vector name='grabber(right).position' x='0' y='0' z='0.1'/></code>
  
-===== attach.rotation =====+===== rotation =====
 Attach orientation in euler degrees relative to parent element or bone. Attach orientation in euler degrees relative to parent element or bone.
-  * Full name: "grabber.attach.rotationor "grabber(id).attach.rotation" +  * Full name: ''grabber.rotation'' or ''grabber(id).rotation'' 
-  * Type: 3-component vector +  * Type: 3-component float vector 
-  * Default Value: (0, 0, 0) +  * Default Value: ''(0, 0, 0)'' 
-  * Example (*.deeclass): <code xml><vector name='grabber(right).attach.rotation' x='-45' y='0' z='0'/></code>+  * Example (*.deeclass): <code xml><vector name='grabber(right).rotation' x='-45' y='0' z='0'/></code>
  
-===== attach.bone =====+===== bone =====
 Name of bone to attach to or empty string to attach to the parent element. Name of bone to attach to or empty string to attach to the parent element.
-  * Full name: "grabber.attach.boneor "grabber(id).attach.bone"+  * Full name: ''grabber.bone'' or ''grabber(id).bone''
   * Type: string   * Type: string
   * Default Value: empty string   * Default Value: empty string
-  * Example (*.deeclass): <code xml><string name='grabber(right).attach.bone'>attach hand.r</string></code>+  * Example (*.deeclass): <code xml><string name='grabber(right).bone'>attach hand.r</string></code> 
 + 
 +====== Events ====== 
 + 
 +===== spotGrabbed ===== 
 + 
 +Grabber grabbed grab spot. 
 + 
 +===== spotReleased ===== 
 + 
 +Grabber released grab spot. 
 + 
 +===== touchGrabSpot ===== 
 + 
 +Start touching grab spot. 
 + 
 +===== untouchGrabSpot ===== 
 + 
 +Stop touching grab spot. 
 + 
 +===== canTouchGrabSpot ===== 
 + 
 +Grab spot can be touched if all listeners return true. 
 + 
 +===== enabledChanged ===== 
 + 
 +Grabber enabled changed.
  
 ====== Required Behaviors ====== ====== Required Behaviors ======
Line 61: Line 84:
 ====== Optional Behaviors ====== ====== Optional Behaviors ======
  
-This behavior does not support optional behaviors.+  * [[behavior_collider|ECBehaviorCollider]]: If used attaches grab spot touch collider to collider 
 +  * [[behavior_vrhand|ECBehaviorVRHand]]: If used attaches grab spot touch collider to VR hand collider
  
 ====== Persistency ====== ====== Persistency ======
  
-Saves these parameters: +This behavior does support element class to be persistable (setPersistable).
-  * Enabled +
-  * [[behavior_grabspot|ECBehaviorGrabSpot]]+
  
 ====== API Documentation ====== ====== API Documentation ======
  
-[[https://developer.dragondreams.ch/docs/dragonscript/scriptapi/latest/classDragengine_1_1Scenery_1_1ECBehaviorGrabber.html|ECBehaviorGrabber]].+#@LinkApiDocDEDS2_HTML~classDragengine_1_1Scenery_1_1ECBehaviorGrabber.html,ECBehaviorGrabber~@#.
  
-Since DragonScript Module Version **1.9**+Since DragonScript Module Version ''1.9''
  
 ====== Use Cases ====== ====== Use Cases ======
Line 107: Line 129:
 </code> </code>
  
-The [[https://developer.dragondreams.ch/docs/dragonscript/scriptapi/latest/classDragengine_1_1Scenery_1_1BaseVRActorClass.html|BaseVRActorClass]] provides full VR support including ECBehaviorGrabber for both hands.+The #@LinkApiDocDEDS2_HTML~classDragengine_1_1Scenery_1_1BaseVRActorClass.html,BaseVRActorClass~@# provides full VR support including ECBehaviorGrabber for both hands. 
 + 
 +====== Behavior Factory ====== 
 + 
 +Using element class supporting adding behaviors the behavior can be added like this: 
 +<code xml> 
 +<?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='ECBehaviorGrabber' id='right'> 
 +    <!-- optional: use vr hand with id instead of empty string --> 
 +    <string name='vrHand'>right</string> 
 +     
 +    <!-- optional: set collision filter. default value '4:1' which means 
 +                   category BaseGameApp.CollisionFilterBit.trigger 
 +                   filter BaseGameApp.CollisionFilterBit.dynamic. 
 +                   format is '', 'category' or 'category:filter' where category and filter 
 +                   are a list of bits to set. --> 
 +    <string name='collisionFilter'>4:1 2</string> 
 +     
 +    <!-- set element properties. omit property prefix if used inside behavior tag --> 
 +    <string name='.bone'>hand.r</string> 
 +  </behavior> 
 +   
 +  <!-- for adding multiple behaviors use unique identifiers --> 
 +  <behavior type='ECBehaviorCustomColor' id='left'> 
 +    <string name='vrHand'>left</string> 
 +    <string name='.bone'>hand.l</string> 
 +  </behavior> 
 +</elementClass> 
 +</code>
  
 ====== Live Examples ====== ====== Live Examples ======
  
   * [[https://github.com/LordOfDragons/deexamples|DEExamples Repository]]: ExampleVR project.   * [[https://github.com/LordOfDragons/deexamples|DEExamples Repository]]: ExampleVR project.
dragengine/modules/dragonscript/behavior_grabber.1644086199.txt.gz · Last modified: 2022/02/05 18:36 by dragonlord