Start Page » DragonScript Scripting Language » Behavior Elements: Quick and Easy Development » ECBehaviorBodyTilting
behavior adding body tilting support for actors projected to ground.
Helps actors with appropriate animator setup to align their body to uneven ground underneath. This is done by using a set of collider collision tests to probe the terain. The result is handed over to a Locomotion insatance to calculate the tilting values. These values are then set to animator controlled linked to tilting values.
Behavior uses 4 collider collision tests located front-left, front-right, back-left and back-right.
To this behavior add it and either set the class properties or call setShape(), setOrigin() and setDirection() to initialize. Then use Locomotion.addControllerMapping() with Locomotion.ATTR_TILT_OFFSET
, Locomotion.ATTR_TILT_VERTICAL
and Locomotion.ATTR_TILT_HORIZONTAL
for animators supporting tilting.
See also:
This behavior can be used only once on an element.
Element class properties have the prefix bodyTilting.
.
Set test direction. Defines the Y coordinate of the direction. X and Z coordinates are 0.
bodyTilting.testDirection
<float name='bodyTilting.testDirection'>-0.8</float>
Set test origin. Used as setOrigin(x,z,y) hence right=x, front=z, up=y .
bodyTilting.testOrigin
or bodyTilting({id}).testOrigin
<vector name='bodyTilting.testOrigin' x='0.3' y='0.3' z='0.3'/>
This behavior can be used only once on an element.
This behavior does not support optional behaviors.
This behavior does not required element class to be persistable (setPersistable).
Since DragonScript Module Version 1.0
This example defines an element which body tilting support.
class MyElement extends BehaviorElementClass public var ECBehaviorComponent component public var ECBehaviorCollider collider public var ECBehaviorColliderAI colliderAI public var ECBehaviorLocomotion locomotion public var ECBehaviorProjectToGround projectToGround public var ECBehaviorBodyTilting bodyTilting func new() component = ECBehaviorComponent.new(this, null) collider = ECBehaviorCollider.new(this, component) colliderAI = ECBehaviorColliderAI.new(this, collider) locomotion = ECBehaviorLocomotion.new(this, colliderAI) projectToGround = ECBehaviorProjectToGround.new(this, colliderAI) bodyTilting = ECBehaviorBodyTilting.new(this, locomotion, projectToGround) 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='ECBehaviorProjectToGround'/> <behavior type='ECBehaviorBodyTilting'> <!-- set element properties. omit property prefix if used inside behavior tag --> <float name='.testDirection'>-0.8</float> </behavior> <!-- for adding multiple behaviors use unique identifiers --> <behavior type='ECBehaviorBodyTilting' id='second'/> </elementClass>