{{tag>dragonscript behavior}} [[:start|Start Page]] >> [[main|DragonScript Scripting Language]] >> [[abstractions#behavior_elementsquick_and_easy_development|Behavior Elements: Quick and Easy Development]] >> **ECBehaviorProjectToGround** * [[behaviors_use_cases|Behaviors Explained: By Use-Case]] * [[behaviors_a_to_z|Behaviors Explained: From A to Z]] ====== ECBehaviorProjectToGround ====== Behavior element behavior adding project to ground support for actor AI. Adds TouchSensor. The touch sensor is used to improve performance and requires a shape large enough to enclose the ECBehaviorColliderAI or ECBehaviorCollider (whichever is present) along all the up and down projection range. The touch sensor is attached to collider. The touch sensor uses the collision filter from collider. To use this behavior add it to an actor. The behavior will run during postThink() and projects the actor position down to the ground if enabled. The grounded position is stored and can then be retrieved to work with. By default the behavior is set to automatically apply the grounded position to the actor. This behavior can be desibled for custome project to ground handling. ====== Instance Counts ====== This behavior can be used only once on an element. ====== Element Class Properties ====== Element class properties have the prefix ''projectToGround.'' . ===== applyToActor ===== Set apply projected position automatically to actor during postThink(). If disabled actor actions have to use getGroundedPosition() to place the actor. * Full name: ''projectToGround.applyToActor'' * Type: boolean * Default Value: true * Example (*.deeclass) false ====== Events ====== This behavior has these events: ===== enabledChanged ===== Enabled changed. ===== touchesGroundChanged ===== Actor switched between touching ground and not touching ground. ====== Required Behaviors ====== * [[behavior_colliderai|ECBehaviorColliderAI]] or [[behavior_collider|ECBehaviorCollider]] ====== Optional Behaviors ====== This behavior does not support optional behaviors. ====== Persistency ====== This behavior does support element class to be persistable (setPersistable). ====== API Documentation ====== #@LinkApiDocDEDS2_HTML~classDragengine_1_1Scenery_1_1ECBehaviorProjectToGround.html,ECBehaviorProjectToGround~@#. Since DragonScript Module Version ''1.0'' ====== Use Cases ====== * Project actor down to ground if in reach. ====== Element Class Example ====== This example defines an element which project to ground support. class MyElement extends BehaviorElementClass public var ECBehaviorComponent component public var ECBehaviorCollider collider public var ECBehaviorColliderAI colliderAI public var ECBehaviorProjectToGround projectToGround func new() component = ECBehaviorComponent.new(this, null) collider = ECBehaviorCollider.new(this, component) colliderAI = ECBehaviorColliderAI.new(this, collider) projectToGround = ECBehaviorProjectToGround.new(this, colliderAI) end end ====== Behavior Factory ====== Using element class supporting adding behaviors the behavior can be added like this: false ====== Live Examples ====== * [[https://github.com/LordOfDragons/deexamples|DEExamples Repository]]