Table of Contents

,

Start Page » DragonScript Scripting Language » Behavior Elements: Quick and Easy Development » ECBehaviorGrabSpot

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 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.

touchCollider.localGravity

Local gravity of touch collider if not affected by world gravity.

touchCollider.weight

Weight (mass) of touch collider if dynamic.

touchCollider.enabled

Initial enabled state of touch collider.

touchCollider.shape

Shape of touch collider used to detect grabbers.

touchCollider.rig

Rig resource to use for touch collider.

attach.position

Touch collider attach position relative to parent element or bone.

attach.rotation

Touch collider attach orientation in euler degrees relative to parent element or bone.

attach.bone

Name of bone to attach touch collider to or empty string to attach to the parent element.

Required Behaviors

This behavior does not required other behaviors to be present.

Optional Behaviors

Persistency

Saves these parameters:

API Documentation

ECBehaviorGrabSpot.

Since DragonScript Module Version 1.9

Use Cases

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