Table of Contents

,

Start Page » DragonScript Scripting Language » Abstraction Layers: How you want to build your Game » Behavior Elements » ECBehaviorBodyTilting

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:

Instance Counts

This behavior can be used only once on an element.

Element Class Properties

Element class properties have the prefix bodyTilting. .

testDirection

Set test direction. Defines the Y coordinate of the direction. X and Z coordinates are 0.

testOrigin

Set test origin. Used as setOrigin(x,z,y) hence right=x, front=z, up=y .

Events

This behavior can be used only once on an element.

Required Behaviors

Optional Behaviors

This behavior does not support optional behaviors.

Persistency

This behavior does not required element class to be persistable (setPersistable).

API Documentation

ECBehaviorBodyTilting.

Since DragonScript Module Version 1.0

Use Cases

Element Class Example

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

Behavior Factory

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>

Live Examples