Table of Contents

,

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

ECBehaviorFootStepConfig

Behavior adding a single foot step configuration with a list of events. Optionally a list of sounds can be defined which is assigned to the events. All events share the same sounds and play sound parameters.

Instance Counts

Multiple ECBehaviorFootStepConfig to add multiple foot step configurations.

Element Class Properties

Element class properties have the prefix footStepConfig. or footStepConfig({id}). if id is not empty.

configId

Set identifier of configuration.

interval

Set interval in seconds between repeating foot steps.

controllerName

Set actor animated controller name to use as elapsed time. Typically a controller updated by the moved distance is used. This allows to synchronize foot steps to animations easily. Keep in mind that event times are measured in the range from 0 to 1 instead of seconds if a controller is used. This allows animations of different length to be used with the same configuration.

sounds

List of path of sound resource to randomly choose from.

volume

Set volume of foot step sound played.

range

Set range of foot step sound played.

rollOff

Set rollOff of foot step sound played. Determines of quickly the sound volume diminishes towards the range. Value is in the range from 0 to 1 with 0.1 being a natural roll-off

offset

Offset relative to element position to play sound at.

type

Set custom type identifier. Optional value which can be used by behaviors to play custom tailored sounds.

eventTimes

List of event times. For each list entry an event is added to the configuration using the properties outline above. If controllerName is empty the times are in seconds. If controllerName is not empty the times are in the range from 0 to 1 representing relative time values across the controller value range. Event time values must be in increasing order.

Events

This behavior provides no events.

Required Behaviors

This behavior requires no other behaviors.

Optional Behaviors

Persistency

This behavior does not require element class persistency (setPersistable).

API Documentation

ECBehaviorFootStepConfig.

Since DragonScript Module Version 1.26

Use Cases

Element Class Example

This example defines an element which two foot step configurations.

class MyElement extends BehaviorElementClass
  public var ECBehaviorFootSteps footSteps
  public var ECBehaviorFootStepConfig footStepsWalk, footStepsRun
  func new()
    footSteps = ECBehaviorFootSteps.new(this)
    footStepsWalk = ECBehaviorFootStepConfig.new(this, footSteps, "walk")
    footStepsWalk.getInterval().setValue(0.6)
    footStepsRun = ECBehaviorFootStepConfig.new(this, footSteps, "run")
    footStepsRun.getInterval().setValue(0.4)
  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'/>
 
  <behavior type='ECBehaviorFootStepConfig' id='walk'>
    <!-- behavior factory automatically assigns all required behaviors -->
 
    <!-- set element properties. omit property prefix if used inside behavior tag -->
    <string name='.configId'>walk</string>
    <float name='.interval'>0.6</float>
    <float name='.volume'>0.2</float>
    <float name='.range'>20</float>
    <list name='.sounds'>
      <string>/content/sound/footstep1.ogg</string>
      <string>/content/sound/footstep2.ogg</string>
    </list>
    <list name='.eventTimes'>
      <float>0.5</float>
    </list>
  </behavior>
 
  <behavior type='ECBehaviorFootStepConfig' id='run'>
    ...
  </behavior>
</elementClass>

Live Examples