{{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]] >> **ECBehaviorRideOn** * [[behaviors_use_cases|Behaviors Explained: By Use-Case]] * [[behaviors_a_to_z|Behaviors Explained: From A to Z]] ====== ECBehaviorRideOn ====== Behavior adding support to actors to ride on [[behavior_ridable|ECBehaviorRidable]]. If [[behavior_projecttoground|ECBehaviorProjectToGround]] and [[behavior_colliderai|ECBehaviorColliderAI]] are enabled sets the ridable to the ground element if element supports [[behavior_ridable|ECBehaviorRidable]]. Otherwise clears the ridable. Sometimes it is necessary to prevent the ridable to change although it usually would. This can be for example if an actor interacts with an object like sitting on a chair. Projecting to ground usually has to be disabled in this case to prevent the actor climbing on the chair instead of sitting on it. In general this is not a problem since the actor is usually not riding on another element. If tough the actor does ride on another element disabling projecting to ground will clear the ridable. This in turn causes the element to no more move together with the ridable element causing issues. To prevent this problem the ridable can be locked using setLocked(). While locked changes due to ECBehaviorProjectToGround changes will not cause setRidable() to be called. While locked you can still manually call setRidable() to assign a ridable of your choice. ====== Instance Counts ====== This behavior can be used only once on an element. ====== Element Class Properties ====== Element class properties have the prefix ''rideOn.'' . ====== Events ====== This behavior has these events: ===== ridableChanged ===== Ridable changed. Element begins or stops touching a [[behavior_ridable|ECBehaviorRidable]]. ====== Required Behaviors ====== * [[behavior_locomotion|ECBehaviorLocomotion]] * [[behavior_projecttoground|ECBehaviorProjectToGround]] ====== 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_1ECBehaviorRideOn.html,ECBehaviorRideOn~@#. Since DragonScript Module Version ''1.0'' ====== Use Cases ====== * Allow actor riding elements supporting [[behavior_ridable|ECBehaviorRidable]]. ====== Element Class Example ====== This example defines an element which can ride on other elements. class MyElement extends BehaviorElementClass public var ECBehaviorComponent component public var ECBehaviorCollider collider public var ECBehaviorColliderAI colliderAI public var ECBehaviorLocomotion locomotion public var ECBehaviorNavigator navigator public var ECBehaviorProjectToGround projectToGround public var ECBehaviorRideOn rideOn func new() component = ECBehaviorComponent.new(this, null) collider = ECBehaviorCollider.new(this, component) colliderAI = ECBehaviorColliderAI.new(this, collider) locomotion = ECBehaviorLocomotion.new(this, colliderAI) navigator = ECBehaviorNavigator.new(this) projectToGround = ECBehaviorProjectToGround.new(this, colliderAI) rideOn = ECBehaviorRideOn.new(this, locomotion, projectToGround) end end ====== Behavior Factory ====== Using element class supporting adding behaviors the behavior can be added like this: value ====== Live Examples ====== * [[https://github.com/LordOfDragons/deexamples|DEExamples Repository]]