{{tag>dragonscript behavior}} [[:start|Start Page]] >> [[main|DragonScript Scripting Language]] >> [[dragengine:modules:dragonscript:abstractions|Abstraction Layers: How you want to build your Game]] >> [[dragengine:modules:dragonscript:behavior_elements|Behavior Elements]] >> **ECBehaviorBodyTilting** * [[behaviors_use_cases|Behaviors Explained: By Use-Case]] * [[behaviors_a_to_z|Behaviors Explained: From A to Z]] ====== 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: * [[dragengine:modules:dragonscript:locomotion#body_tilting|Locomotion]] ====== 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. * Full name: ''bodyTilting.testDirection'' * Type: float * Default Value: -0.6 * Example (*.deeclass) -0.8 ===== testOrigin ===== Set test origin. Used as setOrigin(x,z,y) hence right=x, front=z, up=y . * Full name: ''bodyTilting.testOrigin'' or ''bodyTilting({id}).testOrigin'' * Type: 3-component float vector * Default Value: (0.2,0.2,0.2) * Example (*.deeclass) ====== Events ====== This behavior can be used only once on an element. ====== Required Behaviors ====== * [[behavior_locomotion|ECBehaviorLocomotion]] * [[behavior_projecttoground|ECBehaviorProjectToGround]] ====== Optional Behaviors ====== This behavior does not support optional behaviors. ====== Persistency ====== This behavior does not required element class to be persistable (setPersistable). ====== API Documentation ====== #@LinkApiDocDEDS2_HTML~classDragengine_1_1Scenery_1_1ECBehaviorBodyTilting.html,ECBehaviorBodyTilting~@#. Since DragonScript Module Version ''1.0'' ====== Use Cases ====== * Align actor with ground in a more sophisticated way than just using ground normal. ====== 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: -0.8 ====== Live Examples ====== * [[https://github.com/LordOfDragons/deexamples|DEExamples Repository]]