{{tag>motioncapture democap behavior}}
[[:start|Start Page]] >> [[main|DEMoCap: Drag[en]gine Motion Capture]] >> [[democap:elementclasses|XML Element Classes]] >> ** ECBGrabAttach **
====== ECBGrabAttach ======
Behavior adding support to attach object to actor while being grabbed. This behavior can be used on the element to grab or on an attached element to grab the parent.
To grab the element itself [[dragengine:modules:dragonscript:behavior_attachable|ECBehaviorAttachable]] has to be present.
To grab the parent the parent object ID has to be set (stub.setAttachTo()) together with an optional bone. While entering the game world element is attached to the parent using relative attachment.
====== Instance Counts ======
This behavior can be used only once on an element.
This element behavior can be present multiple times in a BehaviorElement. In this case use a unique identifier to distinguish the individual behavior instances.
====== Element Class Properties ======
Element class properties have the prefix ''grabAttach.'' or ''grabAttach({id}).'' if id is not empty.
===== bone =====
Bone to attach actor hand to or empty string to attach to object.
* Full name: ''grabAttach.bone'' or ''grabAttach({id}).bone''
* Type: string
* Default Value: empty string
* Example (*.deeclass) bone
===== immobile =====
Object can not be moved. Useful to prevent object to be accidentially moved until the user explicitely enables it.
* Full name: ''grabAttach.immobile'' or ''grabAttach({id}).immobile''
* Type: boolean
* Default Value: ''false''
* Example (*.deeclass) false
===== ikLockRotation =====
Upon grabbing the bone or object the actor hand IK target is rotation locked. This has the effect of enforcing the actor hand to keep the same rotation relative to the bone or object compared to the time he grabbed the object.
* Full name: ''grabAttach.ikLockRotation'' or ''grabAttach({id}).ikLockRotation''
* Type: boolean
* Default Value: ''false''
* Example (*.deeclass) false
===== align =====
Upon grabbing the bone or object the actor hand IK target is aligned with the attach position and orientation. This has the effect of enforcing the actor hand to snap to a specific position and rotation relative to the bone or object. Typical used for handles where the hand is required to be in the exact right position for the animation to not look wrong.
* Full name: ''grabAttach.align'' or ''grabAttach({id}).align''
* Type: boolean
* Default Value: ''true''
* Example (*.deeclass) true
===== position =====
Position relative to the grab spot.
* Full name: ''grabAttach.position'' or ''grabAttach({id}).position''
* Type: 3-component float vector
* Default Value: ''(0, 0, 0)''
* Example (*.deeclass)
===== rotation =====
Rotation in degrees relative to the grab spot.
* Full name: ''grabAttach.rotation'' or ''grabAttach({id}).rotation''
* Type: 3-component float vector
* Default Value: ''(0, 0, 0)''
* Example (*.deeclass)
====== Events ======
This behavior has no events.
====== Conversation Commands ======
This behavior adds no conversation commands.
====== Conversation Conditions ======
This behavior adds no conversation conditions.
====== Behavior Tree Actions ======
This behavior adds no behavior tree actions.
====== Behavior Tree Conditions ======
This behavior adds no behavior tree conditions.
====== Required Behaviors ======
* [[dragengine:modules:dragonscript:behavior_grabspot|ECBehaviorGrabSpot]]
* [[dragengine:modules:dragonscript:behavior_collider|ECBehaviorCollider]]
* [[behavior_ecbbehaviorguipanels|ECBBehaviorGuiPanels]]
====== Optional Behaviors ======
* [[dragengine:modules:dragonscript:behavior_attachable|ECBehaviorAttachable]]
* [[behavior_ecbshowinteracthandles|ECBShowInteractHandles]]
====== API Documentation ======
Since DEMoCap Version ''1.3''
====== Use Cases ======
* Allow actor to grab object at a specific position.
====== Element Class Example ======
class MyElement extends BehaviorElementClass
public var ECBehaviorComponent component
public var ECBehaviorCollider collider
public var ECBehaviorGrabSpot grabSpot
public var ECBehaviorAttachable attachable
public var ECBBehaviorGuiPanels guiPanels
public var ECBSelectable selectable
public var ECBShowInteractHandles showInteractHandles
public var ECBGrabAttach grabAttach
func new()
component = ECBehaviorComponent.new(this)
collider = ECBehaviorCollider.new(this, component)
grabSpot = ECBehaviorGrabSpot.new(this, collider)
grabSpot.getAttachTouchCollider().getPosition().setVector(Vector.new(0, 0, 0.1))
attachable = ECBehaviorAttachable.new(this, collider)
guiPanels = ECBBehaviorGuiPanels.new(this)
selectable = ECBSelectable.new(this)
showInteractHandles = ECBShowInteractHandles.new(this, guiPanels, selectable)
grabAttach = ECBGrabAttach.new(this, guiPanels, grabSpot, collider, attachable, showInteractHandles)
end
end
====== Behavior Factory ======
Using element class supporting adding behaviors the behavior can be added like this (again create an example which creates a valid element class):
move
rotate
0.2
second
false
====== Live Examples ======