Start Page » DragonScript Scripting Language » Behavior Elements: Quick and Easy Development » 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.
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 have the prefix grabSpot. or grabSpot(id). if id is not empty.
Physics type of touch collider used to detect touching grabbers.
<string name='grabSpotright).touchCollider.physicsType>kinematic</string>
Local gravity of touch collider if not affected by world gravity.
<vector name='grabSpot(right).touchCollider.localGravity' x='0' y='-0.1' z='0'/>
Weight (mass) of touch collider if dynamic.
<float name='grabSpot(right).touchCollider.weight'>0.2</float>
Initial enabled state of touch collider.
<boolean name='grabSpot(right).touchCollider.enabled'>true</float>
Shape of touch collider used to detect grabbers.
<string name='grabber(right).touchCollider.shape'>box:extends,0.1,0.1,0.1</string>
Rig resource to use for touch collider.
<string name='grabSpot(right).touchCollider.rig'>grab_spot.derig</string>
Touch collider attach position relative to parent element or bone.
<vector name='grabSpot(right).attach.position' x='0' y='0' z='0.1'/>
Touch collider attach orientation in euler degrees relative to parent element or bone.
<vector name='grabSpot(right).attach.rotation' x='-45' y='0' z='0'/>
Name of bone to attach touch collider to or empty string to attach to the parent element.
<string name='grabSpot(right).attach.bone'>attach hand.r</string>
This behavior does not required other behaviors to be present.
Saves these parameters:
Since DragonScript Module Version 1.9
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