This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
dragengine:modules:dragonscript:behavior_actorik [2020/06/01 11:28] – created dragonlord | dragengine:modules:dragonscript:behavior_actorik [2024/03/14 16:54] (current) – dragonlord | ||
---|---|---|---|
Line 68: | Line 68: | ||
====== API Documentation ====== | ====== API Documentation ====== | ||
- | [[https:// | + | # |
Since DragonScript Module Version **1.2** | Since DragonScript Module Version **1.2** | ||
Line 78: | Line 78: | ||
< | < | ||
- | // example class applying IK to one body group | + | pin Dragengine.Scenery |
class ObjectElementClass extends BaseActorClass | class ObjectElementClass extends BaseActorClass | ||
| | ||
Line 94: | Line 95: | ||
end | end | ||
- | // example | + | class ActorActionIK extends BAAFirstPerson |
- | class ObjectElement2Class | + | |
+ | |||
+ | | ||
+ | end | ||
+ | |||
+ | // store the behavior so we can use it | ||
+ | | ||
+ | super.initBehaviors() | ||
+ | actorIK = ECBehaviorActorIK.getInstanceIn(actor) | ||
+ | end | ||
+ | |||
+ | // enable IK while this action is assigned to an actor then disable it again. | ||
+ | // using disable() instead of setEnabled(false) also clears the target | ||
+ | | ||
+ | super.activate() | ||
+ | actorIK.setTarget(targetElementToTouch) | ||
+ | actorIK.setEnabled(true) | ||
+ | end | ||
+ | |||
+ | | ||
+ | actorIK.disable() | ||
+ | super.deactivate() | ||
+ | end | ||
+ | end | ||
+ | </ | ||
+ | |||
+ | Example | ||
+ | < | ||
+ | pin Dragengine.Scenery | ||
+ | |||
+ | class ObjectElementClass | ||
| | ||
| | ||
Line 116: | Line 147: | ||
// using this setup actor actions can enable IK handling for each hand | // using this setup actor actions can enable IK handling for each hand | ||
// individually or for both at the same time | // individually or for both at the same time | ||
+ | end | ||
+ | end | ||
+ | |||
+ | class ActorActionIK extends BAAFirstPerson | ||
+ | | ||
+ | | ||
+ | |||
+ | | ||
+ | end | ||
+ | |||
+ | // store the behavior so we can use it | ||
+ | | ||
+ | super.initBehaviors() | ||
+ | actorIKLeft = ECBehaviorActorIK.getInstanceIn(actor, | ||
+ | actorIKRight = ECBehaviorActorIK.getInstanceIn(actor, | ||
+ | end | ||
+ | |||
+ | // enable IK while this action is assigned to an actor then disable it again. | ||
+ | // using disable() instead of setEnabled(false) also clears the target. | ||
+ | // the element is facing us hence our left side is actually on the right side | ||
+ | // from the point of view of the element. the target position is always | ||
+ | // relative to the target element. | ||
+ | | ||
+ | super.activate() | ||
+ | | ||
+ | actorIKLeft.setTarget(targetElementToTouch, | ||
+ | actorIKLeft.setEnabled(true) | ||
+ | | ||
+ | actorIKRight.setTarget(targetElementToTouch, | ||
+ | actorIKRight.setEnabled(true) | ||
+ | | ||
+ | // you can change target position later on using setTargetMatrix(Vector) | ||
+ | end | ||
+ | |||
+ | | ||
+ | actorIKLeft.disable() | ||
+ | actorIKRight.disable() | ||
+ | super.deactivate() | ||
end | end | ||
end | end | ||
</ | </ |