User Tools

Site Tools


dragengine:modules:dragonscript:behavior_ridable

This is an old revision of the document!


ECBehaviorRidable

Behavior adding support to elements to be ridden by actors.

Actors will attach using relative mode if 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).

ParameterValueDescription
countintegerCount of riding ride on instances equals integer value
count.notintegerCount of riding ride on instances does not equal integer value
count.lessintegerCount of riding ride on instances is less than integer value
count.greaterintegerCount of riding ride on instances is greater than integer value
playertrue, falsePlayer is riding

This is an example of using this action:

<sequence>
  <action name='ridable.check'>
    <parameter name='player'>true</parameter>
  </action>
  <!-- actions here run only if player is riding -->
</sequence>

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.

ParameterValueDescription
ridable.countintegerCount of riding ride on instances equals integer value
ridable.count.notintegerCount of riding ride on instances does not equal integer value
ridable.count.lessintegerCount of riding ride on instances is less than integer value
ridable.count.greaterintegerCount of riding ride on instances is greater than integer value
ridable.playertrue, falsePlayer is riding

This is an example of using this condition:

<action name='myAction' id='doing something'>
  <parameter name='ridable.player'>true</parameter>
  <condition>ridable.check</condition>
</action>

Required Behaviors

Optional Behaviors

Persistency

This behavior does support element class to be persistable (setPersistable). Saves selected color.

API Documentation

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:

<?xml version='1.0' encoding='UTF-8'?>
<elementClass name='MyClass' class='GenericBehaviorElement'>
  <behavior type='ECBehaviorComponent'/>
  <behavior type='ECBehaviorCollider'/>
 
  <behavior type='ECBehaviorRidable'>
    <!-- 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>

Live Examples

You could leave a comment if you were logged in.
dragengine/modules/dragonscript/behavior_ridable.1746221650.txt.gz · Last modified: 2025/05/02 21:34 by dragonlord