{{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]].
====== Behavior Tree Actions ======
This behavior adds these behavior tree actions if behavior tree is present.
===== rideOn.check =====
Check one or more ride on parameters. Action succeeds if all parameter value matches their respective ride on parameter otherwise action fails. This action is typically used as first action in a sequence to run the sequence only if a ride on parameter matches (or not).
^Parameter^Value^Description^
|ridable|''true'', ''false''|Riding on an element|
|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.
===== rideOn.check =====
Check one or more ride on parameters. Conditions returns true if all parameter value match their respective ride on parameter. This condition is typically used to run an action or sequence of actions as long as ride on conditions are true.
^Parameter^Value^Description^
|rideOn.ridable|''true'', ''false''|Riding on an element|
This is an example of using this condition:
true
rideOn.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 ======
This behavior sends these state machine events.
===== rideOn.begin =====
Element is riding on a ridable while previously it did not ride on a ridable.
===== rideOn.end =====
Element is not riding on a ridable while previously it has been riding on a ridable.
====== Required Behaviors ======
* [[behavior_locomotion|ECBehaviorLocomotion]]
* [[behavior_projecttoground|ECBehaviorProjectToGround]]
====== 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).
====== 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:
second
second
value
====== Live Examples ======
* [[https://github.com/LordOfDragons/deexamples|DEExamples Repository]]