User Tools

Site Tools


democap:behavior_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 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)
    <string name='grabAttach.bone'>bone</string>

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)
    <boolean name='grabAttach.immobile'>false</boolean>

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)
    <boolean name='grabAttach.ikLockRotation'>false</boolean>

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)
    <boolean name='grabAttach.align'>true</boolean>

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)
    <vector name='grabAttach.position' x='0' y='0' z='0.2'/>

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)
    <vector name='grabAttach.rotation' x='0' y='90' z='0'/>

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

Optional Behaviors

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):

<?xml version='1.0' encoding='UTF-8'?>
<elementClass name='MyClass' class='GenericBehaviorElement'>
  <behavior type='ECBehaviorComponent'/>
  <behavior type='ECBehaviorCollider'/>
  <behavior type='ECBehaviorGrabSpot'/>
  <behavior type='ECBehaviorAttachable'/>
  <behavior type='ECBBehaviorGuiPanels'/>
  <behavior type='ECBSelectable'/>
  <behavior type='ECBShowInteractHandles'>
    <list name='handleSets'>
      <string>move</string>
      <string>rotate</string>
    </list>
    <float name='.handleSize'>0.2</float>
  </behavior>
 
  <behavior type='ECBGrabAttach'>
    <!-- optional: use grab spot with id instead of empty string -->
    <string name='grabSpot'>second</string>
 
    <!-- set element properties. omit property prefix if used inside behavior tag -->
    <boolean name='.align'>false</boolean>
  </behavior>
 
  <!-- for adding multiple behaviors use unique identifiers -->
  <behavior type='ECBGrabAttach' id='second'/>
</elementClass>

Live Examples

You could leave a comment if you were logged in.
democap/behavior_ecbgrabattach.txt · Last modified: 2025/03/22 19:03 by dragonlord