Table of Contents

,

Start Page » DragonScript Scripting Language » Abstraction Layers: How you want to build your Game » Behavior Elements » ECBehaviorFootSteps

ECBehaviorFootSteps

Behavior element behavior adding foot steps support to actors.

Uses a list of events to play random foot steps according to an elapsing time value. The elapsed time is updated with the elapsed game time while the actor is walking. If auto-update is true (which is the default) update() is called automatically by the behavior on thinking. Otherwise the actor has to call update(float) to advance the elapsed time. Independent of auto-updating the actor has to call reset() when standing still to ensure the events fire at the right time.

Events define for an elapsed time the sound to play. This is using a WeightedRandomList allowing to pick a random sound with support to favor certain sounds. The sound is then played at an offset relative to the behavior element with individual sound parameters. The sound parameters and offset are defined for each individual sound allowing special configurations like a pirate walking with a wooden leg.

It is common for actors to switch between different gaits (walking, running, robbing or sneaking). To make this process simple multiple configurations can be stored. The actor can then switch between configurations. Depending on how the animations are set up for the actor changing configuration has to reset the elapsed time or not. The actor is responsible to call reset() if required after switching configurations.

If you want to support different foot step sounds for different materials you should not use multiple configurations since switching them can reset the event timing. Use instead events with empty sound list and use the behavior listener to be notified when sound has to be played. See other behaviors for adding material foot step support as well as other special effects like triggering particle emitters.

Instance Counts

This behavior can be used only once on an element.

Element Class Properties

Element class properties have the prefix footSteps. .

Events

This behavior has these events:

footStep

Foot step triggered.

configurationChanged

Configuration changed.

Behavior Tree Actions

This behavior adds these behavior tree actions if behavior tree is present.

footSteps.set

Set one or more foot steps parameters.

ParameterValueDescription
configurationstringSet active configuration by identifier. Use empty string to clear
elapsedfloatElapsed time in the current interval

This is an example of using this action:

<action name='footSteps.set'>
  <parameter name='configuration'>walk</parameter>
</action>

footSteps.check

Check one or more foot steps parameters. Action succeeds if all parameter value matches their respective foot steps parameter otherwise action fails. This action is typically used as first action in a sequence to run the sequence only if a foot steps parameter matches (or not).

ParameterValueDescription
configurationstringActive configuration identifier (empty string if none is active) matches string value
configuration.notstringActive configuration identifier (empty string if none is active) does not match string value
configuration.startsstringActive configuration identifier (empty string if none is active) starts with string value
configuration.starts.notstringActive configuration identifier (empty string if none is active) does not start with string value
configuration.endsstringActive configuration identifier (empty string if none is active) ends with string value
configuration.ends.notstringActive configuration identifier (empty string if none is active) does not end with string value
configuration.containsstringActive configuration identifier (empty string if none is active) contains string value
configuration.contains.notstringActive configuration identifier (empty string if none is active) does not contain string value
elapsed.lessfloatElapsed time in the current interval is less then value seconds
elapsed.greaterfloatElapsed time in the current interval is greater then value seconds
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='footSteps.check'>
    <parameter name='configuration'>walk</parameter>
  </action>
  <!-- actions here run only if configuration named "walk" is active -->
</sequence>

Behavior Tree Conditions

This behavior adds these behavior tree conditions if behavior tree is present.

footSteps.check

Check one or more foot steps parameters. Conditions returns true if all parameter value match their respective foot steps parameter. This condition is typically used to run an action or sequence of actions as long as foot steps conditions are true.

ParameterValueDescription
footSteps.configurationstringActive configuration identifier (empty string if none is active) matches string value
footSteps.configuration.notstringActive configuration identifier (empty string if none is active) does not match string value
footSteps.configuration.startsstringActive configuration identifier (empty string if none is active) starts with string value
footSteps.configuration.starts.notstringActive configuration identifier (empty string if none is active) does not start with string value
footSteps.configuration.endsstringActive configuration identifier (empty string if none is active) ends with string value
footSteps.configuration.ends.notstringActive configuration identifier (empty string if none is active) does not end with string value
footSteps.configuration.containsstringActive configuration identifier (empty string if none is active) contains string value
footSteps.configuration.contains.notstringActive configuration identifier (empty string if none is active) does not contain string value
footSteps.elapsed.lessfloatElapsed time in the current interval is less then value seconds
footSteps.elapsed.greaterfloatElapsed time in the current interval is greater then value seconds

This is an example of using this condition:

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

State Machine Actions

Same as Behavior Tree Actions.

State Machine Conditions

Same as Behavior Tree Conditions.

State Machine Events

This behavior sends these state machine events.

footSteps.configuration

Foot steps configuration changed.

footSteps.foorStep

Foot step triggered.

Required Behaviors

This behavior requires no other behaviors.

Optional Behaviors

Persistency

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

API Documentation

ECBehaviorFootSteps.

Since DragonScript Module Version 1.0

Use Cases

Element Class Example

This example defines an element which has support for playing footsteps.

class MyElement extends BehaviorElementClass
  public var ECBehaviorFootSteps footSteps
  func new()
    footSteps = ECBehaviorFootSteps.new(this, "color1", "Color 1", Color.blue)
  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='ECBehaviorFootSteps'>
    <!-- optional: use actor animated with id instead of empty string -->
    <string name='actorAnimated'>second</string>
 
    <!-- set if update() is automatically called on postThink(). default is 'true' -->
    <boolean name='autoUpdate'>false</boolean>
 
    <!-- optional: use state machine with id instead of empty string -->
    <string name='stateMachine'>second</string>
 
    <!-- set if update() is automatically called on postThink(). default is 'true' -->
    <boolean name='autoUpdate'>false</boolean>
 
    <!-- set element properties. omit property prefix if used inside behavior tag -->
    <string name='.name'>value</string>
  </behavior>
</elementClass>

Live Examples