{{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]] >> **ECBehaviorRidable** * [[behaviors_use_cases|Behaviors Explained: By Use-Case]] * [[behaviors_a_to_z|Behaviors Explained: From A to Z]] ====== ECBehaviorRidable ====== Behavior adding support to elements to be ridden by actors. Actors will attach using relative mode if [[behavior_projecttoground|ECBehaviorProjectToGround]] hits this element. ====== Instance Counts ====== This behavior can be used only once on an element. ====== Element Class Properties ====== Element class properties have the prefix ''ridable.''. ====== Events ====== ===== beginRiding ===== Ride on instance begins riding. ===== stopRiding ===== Ride on instance stops riding. ====== Behavior Tree Actions ====== This behavior adds these behavior tree actions if behavior tree is present. ===== ridable.check ===== Check one or more ridable parameters. Action succeeds if all parameter value matches their respective ridable parameter otherwise action fails. This action is typically used as first action in a sequence to run the sequence only if a ridable parameter matches (or not). ^Parameter^Value^Description^ |count|integer|Count of riding ride on instances equals integer value| |count.not|integer|Count of riding ride on instances does not equal integer value| |count.less|integer|Count of riding ride on instances is less than integer value| |count.greater|integer|Count of riding ride on instances is greater than integer value| |player|''true'', ''false''|Player is riding| |wait| |If present action returns BTResult.running instead of BTResult.failed to wait until the checks are all fulfilled| This is an example of using this action: true ====== Behavior Tree Conditions ====== This behavior adds these behavior tree conditions if behavior tree is present. ===== ridable.check ===== Check one or more ridable parameters. Conditions returns true if all parameter value match their respective ridable parameter. This condition is typically used to run an action or sequence of actions as long as ridable conditions are true. ^Parameter^Value^Description^ |ridable.count|integer|Count of riding ride on instances equals integer value| |ridable.count.not|integer|Count of riding ride on instances does not equal integer value| |ridable.count.less|integer|Count of riding ride on instances is less than integer value| |ridable.count.greater|integer|Count of riding ride on instances is greater than integer value| |ridable.player|''true'', ''false''|Player is riding| This is an example of using this condition: true ridable.check ====== State Machine Actions ====== Same as [[#behavior_tree_actions|Behavior Tree Actions]]. ====== State Machine Conditions ====== Same as [[#behavior_tree_conditions|Behavior Tree Conditions]]. ====== State Machine Events ====== ===== ridable.beginRiding ===== Ride on instance begins riding. ===== ridable.stopRiding ===== Ride on instance stops riding. ====== Required Behaviors ====== * [[behavior_collider|ECBehaviorCollider]] ====== Optional Behaviors ====== * [[behavior_behaviortree|ECBehaviorBehaviorTree]]: Add actions and conditions for behavior trees to use. * [[behavior_statemachine|ECBehaviorStateMachine]]: Add actions and conditions for state machine to use and events to send to the state machine. ====== Persistency ====== This behavior does support element class to be persistable (setPersistable). Saves selected color. ====== API Documentation ====== #@LinkApiDocDEDS2_HTML~classDragengine_1_1Scenery_1_1ECBehaviorRidable.html,ECBehaviorRidable~@#. Since DragonScript Module Version ''1.0'' ====== Use Cases ====== * Player can ride on geometry if it is moving and the actor is touching it. ====== Element Class Example ====== This example defines an element which can be rode by the player. class MyElement extends BehaviorElementClass public var ECBehaviorComponent component public var ECBehaviorCollider collider public var ECBehaviorRidable ridable func new() component = ECBehaviorComponent.new(this, null) collider = ECBehaviorCollider.new(this, component) ridable = ECBehaviorRidable.new(this, collider) end end ====== Behavior Factory ====== Using element class supporting adding behaviors the behavior can be added like this: second second value ====== Live Examples ====== * [[https://github.com/LordOfDragons/deexamples|DEExamples Repository]]