This is an old revision of the document!
Start Page » DragonScript Scripting Language » Abstraction Layers: How you want to build your Game » Behavior Elements » ECBehaviorVRBody
Behavior in action
Behavior element behavior adding VR Body tracking support to actor. This behavior tracks a body tracker input device providing bone pose data for the upper or full body of the user. A body rig describing the skeleton is optionally provided by the tracking device. The behavior uses this rig to do automatic retargeteting of tracked pose to the actor model.
This behavior requires ECBehaviorActorAnimated to obtain the component to animate. The behavior registers itself as listener to ECBehaviorActorAnimated and is applied after animators defined by behaviors from BaseActorClass. In particular this applies the tracked poses after the base animation and conversation system animations. Additional animations can then be applied on top of the body tracked animation using other behaviors.
This behavior applies inverse kinematics to arms after applying the pose. This componesates positional differences due to differing rigs and ensures the hands are located where the ECBehaviorVRHand would be if body tracking is not used.
This behavior applies only body bone poses including the hand wrists. Palm and finger poses are applied by ECBehaviorVRHandPose to avoid conflicts and simplify the implementation.
This behavior can be added only once to an element.
Element class properties have the prefix vrBody..
Apply only orientation of tracked bones or position and orientation. Applying only the the orientation of tracked bones is recommended. The behavior applies inverse kinematics to arms to compensate for positional differences.
vrBody.onlyRotationtrue<boolean name='vrBody.onlyRotation'>false</boolean>
Applies lower body bone poses (legs and feet) if supported by the input device provides full body tracking. Upper body bones (spine, chest, arms, neck, head) are always applied.
vrBody.enableLowerBodytrue<boolean name='vrBody.enableLowerBody'>false</boolean>
Name of the origin bone in the actor rig. This bone is used as the reference point for aligning the tracked body pose with the actor model. Set to empty string to not use an origin bone.
vrBody.boneOrigin“origin”<string name='vrBody.boneOrigin'>hips</string>
These properties define the names of upper body bones in the actor rig. Set to empty string if not present or not desired to be animated.
| Property | Default Value | Tracked Bone |
|---|---|---|
vrBody.boneHips | hips | Hips |
vrBody.boneSpineLower | spineLower | Lower spine |
vrBody.boneSpineMiddle | spineMiddle | Middle spine |
vrBody.boneSpineUpper | spineUpper | Upper spine |
vrBody.boneChest | chest | Chest |
vrBody.boneNeck | neck | Neck |
vrBody.boneHead | head | Head |
vrBody.boneLeftShoulder | shoulder.l | Left shoulder |
vrBody.boneLeftScapula | scapula.l | Left scapula |
vrBody.boneLeftArmUpper | armUpper.l | Left upper arm |
vrBody.boneLeftArmLower | armLower.l | Left lower arm |
vrBody.boneLeftHandWristTwist | wristTwist.l | Left wrist twist |
vrBody.boneLeftHandWrist | wrist.l | Left wrist |
vrBody.boneRightShoulder | shoulder.r | Right shoulder |
vrBody.boneRightScapula | scapula.r | Right scapula |
vrBody.boneRightArmUpper | armUpper.r | Right upper arm |
vrBody.boneRightArmLower | armLower.r | Right lower arm |
vrBody.boneRightHandWristTwist | wristTwist.r | Right wrist twist |
vrBody.boneRightHandWrist | wrist.r | Right wrist |
Example (*.deeclass):
<string name='vrBody.boneHips'>waist</string> <string name='vrBody.boneLeftHandWrist'>hand.l</string>
These properties define the names of lower body bones in the actor rig. These are only used if the input device provides full body tracking and vrBody.enableLowerBody is set to true. Set the property to empty string if bone is not present or not desired to be animated.
| Property | Default Value | Tracked Bone |
|---|---|---|
vrBody.boneLeftUpperLeg | upperLeg.l | Left upper leg |
vrBody.boneLeftLowerLeg | lowerLeg.l | Left lower leg |
vrBody.boneLeftFootAnkleTwist | footAnkleTwist.l | Left ankle twist |
vrBody.boneLeftFootAnkle | footAnkle.l | Left ankle |
vrBody.boneLeftFootSubtalar | footSubtalar.l | Left foot subtalar |
vrBody.boneLeftFootTransverse | footTransverse.l | Left foot transverse |
vrBody.boneLeftFootBall | footBall.l | Left foot ball |
vrBody.boneRightUpperLeg | upperLeg.r | Right upper leg |
vrBody.boneRightLowerLeg | lowerLeg.r | Right lower leg |
vrBody.boneRightFootAnkleTwist | footAnkleTwist.r | Right ankle twist |
vrBody.boneRightFootAnkle | footAnkle.r | Right ankle |
vrBody.boneRightFootSubtalar | footSubtalar.r | Right foot subtalar |
vrBody.boneRightFootTransverse | footTransverse.r | Right foot transverse |
vrBody.boneRightFootBall | footBall.r | Right foot ball |
Example (*.deeclass):
<string name='vrBody.boneLeftUpperLeg'>leg.u.l</string> <string name='vrBody.boneLeftFootAnkle'>foot.l</string>
Input device attached and ready to use.
Input device detached and no more usable.
Bone rig skeleton provided by the input device changed. Happens when the input device recalibrates the user. Bones are automatically retargeted to the new body rig.
This behavior adds these behavior tree actions if a behavior tree is present.
Check one or more VR body parameters. Action succeeds if all parameter values match their respective VR body parameter otherwise action fails. This action is typically used as first action in a sequence to run the sequence only if a VR body parameter matches (or not).
| Parameter | Value | Description |
|---|---|---|
| attached | true, false | Body tracker is attached |
| wait | If present action returns BTResult.running instead of BTResult.failed to wait until the checks are all fulfilled |
This is an example of using this action:
<sequence> <action name='vrBody.check'> <parameter name='attached'>true</parameter> </action> <!-- actions here run only if body tracker is attached --> </sequence>
This behavior adds these behavior tree conditions if a behavior tree is present.
Check one or more VR body parameters. Condition returns true if all parameter values match their respective VR body parameter. This condition is typically used to run an action or sequence of actions as long as VR body conditions are true.
| Parameter | Value | Description |
|---|---|---|
| vrBody.attached | true, false | Body tracker is attached |
This is an example of using this condition:
<action name='myAction' id='doing something'> <parameter name='vrBody.attached'>true</parameter> <condition>vrBody.check</condition> </action>
Same as Behavior Tree Actions.
Same as Behavior Tree Conditions.
This behavior sends these state machine events.
Input device has been attached.
Input device has been detached.
Body rig of the input device changed. This happens when the input device recalibrates the user.
This behavior does not use persistency.
Since DragonScript Module Version 1.31
The following example creates an element class with VR body tracking.
class MyElement extends BehaviorElementClass
func new()
// Add basic components required for player body
var ECBehaviorComponent component = ECBehaviorComponent.new(this, null)
var ECBehaviorCollider collider = ECBehaviorCollider.new(this, component)
var ECBehaviorColliderAI colliderAI = ECBehaviorColliderAI.new(this, collider)
var ECBehaviorLocomotion locomotion = ECBehaviorLocomotion.new(this, colliderAI)
// Add actor animated allowing to animate player body
var ECBehaviorActorAnimated actorAnimated = ECBehaviorActorAnimated.new(this, component, locomotion)
// Add VR Playspace behavior. Base behavior required by all VR behaviors
var ECBehaviorVRPlayspace vrPlayspace = ECBehaviorVRPlayspace.new(this)
// Add VR HMD behavior. With this behavior present VRPlayerControlledActorCameraDirector
// can attach the HMD to the in-game camera
ECBehaviorVRHMD.new(this, vrPlayspace)
// Add body tracking
ECBehaviorVRBody.new(this, vrPlayspace, actorAnimated)
// Add left and right hand behaviors. Add them after the body behavior to apply them afterwards
...
end
end
Using element class supporting adding behaviors the behavior can be added like this:
<?xml version='1.0' encoding='UTF-8'?> <elementClass name='MyClass' class='GenericBehaviorElement'> <behavior type='ECBehaviorComponent'/> <behavior type='ECBehaviorCollider'/> <behavior type='ECBehaviorColliderAI'/> <behavior type='ECBehaviorLocomotion'/> <behavior type='ECBehaviorActorAnimated'/> <behavior type='ECBehaviorVRPlayspace'/> <behavior type='ECBehaviorVRHMD'/> <behavior type='ECBehaviorVRBody'> <!-- optional: use ECBehaviorActorAnimated with identifier instead of default one. --> <string name='actorAnimated'>identifier</string> <!-- optional: use BaseGameApp binding manager. game can add more supported values. default is 'default' --> <string name='bindingManager'>default</string> <!-- optional: add behavior trees. default adds all behavior trees. --> <list name='behaviorTrees'> <string/> <!-- add behavior with empty identifier --> <string>default</string> <!-- add behavior with 'default' identifier --> </list> <!-- optional: add state machines. default adds all state machines. --> <list name='stateMachines'> <string/> <!-- add behavior with empty identifier --> <string>default</string> <!-- add behavior with 'default' identifier --> </list> <!-- set element properties. omit property prefix if used inside behavior tag --> <boolean name='.onlyRotation'>false</boolean> <boolean name='.enableLowerBody'>false</boolean> <!-- optional: override bone names if character rig uses different naming --> <string name='.boneHips'>waist</string> <string name='.boneLeftHandWrist'>hand.l</string> <string name='.boneRightHandWrist'>hand.r</string> </behavior> </elementClass>