Start Page » DragonScript Scripting Language » Abstraction Layers: How you want to build your Game » Behavior Elements » ECBehaviorRideOn
Behavior adding support to actors to ride on ECBehaviorRidable.
If ECBehaviorProjectToGround and ECBehaviorColliderAI are enabled sets the ridable to the ground element if element supports 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.
This behavior can be used only once on an element.
Element class properties have the prefix rideOn.
.
This behavior has these events:
Ridable changed. Element begins or stops touching a ECBehaviorRidable.
This behavior adds these behavior tree actions if behavior tree is present.
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:
<sequence> <action name='rideOn.check'> <parameter name='ridable'>true</parameter> </action> <!-- actions here run only if riding on an element --> </sequence>
This behavior adds these behavior tree conditions if behavior tree is present.
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:
<action name='myAction' id='doing something'> <parameter name='rideOn.ridable'>true</parameter> <condition>rideOn.check</condition> </action>
Same as Behavior Tree Actions.
Same as Behavior Tree Conditions.
This behavior sends these state machine events.
Element is riding on a ridable while previously it did not ride on a ridable.
Element is not riding on a ridable while previously it has been riding on a ridable.
This behavior does support element class to be persistable (setPersistable).
Since DragonScript Module Version 1.0
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
Using element class supporting adding behaviors the behavior can be added like this:
<?xml version='1.0' encoding='UTF-8'?> <elementClass name='MyClass' class='GenericBehaviorElement'> <behavior type='ECBehaviorComponent'/> <behavior type='ECBehaviorCollider'/> <behavior type='ECBehaviorColliderAI'/> <behavior type='ECBehaviorLocomotion'/> <behavior type='ECBehaviorNavigator'/> <behavior type='ECBehaviorProjectToGround'/> <behavior type='ECBehaviorRideOn'> <!-- optional: use behavior tree with id instead of empty string --> <string name='behaviorTree'>second</string> <!-- optional: use state machine with id instead of empty string --> <string name='stateMachine'>second</string> <!-- set element properties. omit property prefix if used inside behavior tag --> <string name='.name'>value</string> </behavior> </elementClass>