{{tag>dragonscript behavior}} [[:start|Start Page]] >> [[main|DragonScript Scripting Language]] >> [[abstractions#behavior_elementsquick_and_easy_development|Behavior Elements: Quick and Easy Development]] >> **ECBehaviorGrabSpot** * [[behaviors_use_cases|Behaviors Explained: By Use-Case]] * [[behaviors_a_to_z|Behaviors Explained: From A to Z]] ====== ECBehaviorGrabSpot ====== Behavior adding support to define grab spot for actors. Defines position and orientation where the actor can grab the owner element. Grab spots are typically used for physics interaction like VR hand use but can be used also with mouse interaction. The actual grabbing interaction, exact grab location and orientation as well as attaching logic is handled by other behaviors using listening. This behavior also tracks if an actor is grabbing the grab spot. Hence at most one actor can grab an grab spot at each time. Elements able to grab a grab spot have to use the [[behavior_grabber|ECBehaviorGrabber]] behavior. Both the grab spot and the grabber have to persist the other behavior. During restoring no notifications are triggered this way. ====== Instance Counts ====== This behavior can be used multiple times on an element to add different grab spots. Use the behavior identifier to tell them apart. ====== Element Class Properties ====== Element class properties have the prefix **grabSpot.** or **grabSpot(id)**. if id is not empty. ===== touchCollider.physicsType ===== Physics type of touch collider used to detect touching grabbers. * Full name: "grabSpot.touchCollider.physicsType" or "grabSpot(id).touchCollider.physicsType" * Type: string of values "none", "kinematic" and "dynamic" * Default Value: "kinematic" * Example (*.deeclass): ===== touchCollider.weight ===== Weight (mass) of touch collider if dynamic. * Full name: "grabber.touchCollider.weight" or "grabber(id).touchCollider.weight" * Type: float * Default Value: 1 * Example (*.deeclass): 0.2 ===== touchCollider.enabled ===== Initial enabled state of touch collider. * Full name: "grabber.touchCollider.enabled" or "grabber(id).touchCollider.enabled" * Type: boolean * Default Value: true * Example (*.deeclass): true ===== touchCollider.shape ===== Shape of touch collider used to detect grabbers. * Full name: "grabSpot.touchCollider.shape" or "grabSpot(id).touchCollider.shape" * Type: string (shape list encoding) * Default Value: empty string * Example (*.deeclass): box:extends,0.1,0.1,0.1 ===== touchCollider.rig ===== Rig resource to use for touch collider. * Full name: "grabSpot.touchCollider.rig" or "grabSpot(id).touchCollider.rig" * Type: string (rig resource path, for example *.derig) * Default Value: empty path * Example (*.deeclass): grab_spot.derig ===== attach.position ===== Touch collider attach position relative to parent element or bone. * Full name: "grabSpot.attach.position" or "grabSpot(id).attach.position" * Type: 3-component vector * Default Value: (0, 0, 0) * Example (*.deeclass): ===== attach.rotation ===== Touch collider attach orientation in euler degrees relative to parent element or bone. * Full name: "grabSpot.attach.rotation" or "grabSpot(id).attach.rotation" * Type: 3-component vector * Default Value: (0, 0, 0) * Example (*.deeclass): ===== attach.bone ===== Name of bone to attach touch collider to or empty string to attach to the parent element. * Full name: "grabSpot.attach.bone" or "grabSpot(id).attach.bone" * Type: string * Default Value: empty string * Example (*.deeclass): attach hand.r ====== Required Behaviors ====== This behavior does not required other behaviors to be present. ====== Optional Behaviors ====== * [[behavior_collider|ECBehaviorCollider]]: If used attaches grab spot touch collider to collider ====== Persistency ====== Saves these parameters: * Enabled * [[behavior_grabber|ECBehaviorGrabber]] ====== API Documentation ====== #@LinkApiDocDEDS2_HTML~classDragengine_1_1Scenery_1_1ECBehaviorGrabSpot.html,ECBehaviorGrabSpot~@#. Since DragonScript Module Version **1.9** ====== Use Cases ====== * Allow player to grab objects in VR with his hands. * Add different grab spots on an object in VR to alter the interactions the player can do. ====== Element Class Example ====== class ExampleElementClass extends BehaviorElementClass public var ECBehaviorComponent component public var ECBehaviorCollider collider public var ECBehaviorGrabSpot grabSpot public func new() super("ExampleElement") // Create component and collider to give element a look and feeling component = ECBehaviorComponent.new(this) collider = ECBehaviorCollider.new(this, component) // Create grab spot 10cm along Z axis grabSpot = ECBehaviorGrabSpot.new(this, collider) grabSpot.getAttachTouchCollider().getPosition().setVector(Vector.new(0, 0, 0.1)) end end ====== Live Examples ====== * [[https://github.com/LordOfDragons/deexamples|DEExamples Repository]]: ExampleVR project.