{{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]] >> **ECBehaviorFootSteps** * [[behaviors_use_cases|Behaviors Explained: By Use-Case]] * [[behaviors_a_to_z|Behaviors Explained: From A to Z]] ====== 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. ^Parameter^Value^Description^ |configuration|string|Set active configuration by identifier. Use empty string to clear| |elapsed|float|Elapsed time in the current interval| This is an example of using this action: walk ===== 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). ^Parameter^Value^Description^ |configuration|string|Active configuration identifier (empty string if none is active) matches string value| |configuration.not|string|Active configuration identifier (empty string if none is active) does not match string value| |configuration.starts|string|Active configuration identifier (empty string if none is active) starts with string value| |configuration.starts.not|string|Active configuration identifier (empty string if none is active) does not start with string value| |configuration.ends|string|Active configuration identifier (empty string if none is active) ends with string value| |configuration.ends.not|string|Active configuration identifier (empty string if none is active) does not end with string value| |configuration.contains|string|Active configuration identifier (empty string if none is active) contains string value| |configuration.contains.not|string|Active configuration identifier (empty string if none is active) does not contain string value| |elapsed.less|float|Elapsed time in the current interval is less then value seconds| |elapsed.greater|float|Elapsed 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: walk ====== 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. ^Parameter^Value^Description^ |footSteps.configuration|string|Active configuration identifier (empty string if none is active) matches string value| |footSteps.configuration.not|string|Active configuration identifier (empty string if none is active) does not match string value| |footSteps.configuration.starts|string|Active configuration identifier (empty string if none is active) starts with string value| |footSteps.configuration.starts.not|string|Active configuration identifier (empty string if none is active) does not start with string value| |footSteps.configuration.ends|string|Active configuration identifier (empty string if none is active) ends with string value| |footSteps.configuration.ends.not|string|Active configuration identifier (empty string if none is active) does not end with string value| |footSteps.configuration.contains|string|Active configuration identifier (empty string if none is active) contains string value| |footSteps.configuration.contains.not|string|Active configuration identifier (empty string if none is active) does not contain string value| |footSteps.elapsed.less|float|Elapsed time in the current interval is less then value seconds| |footSteps.elapsed.greater|float|Elapsed time in the current interval is greater then value seconds| This is an example of using this condition: true footSteps.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. ===== footSteps.configuration ===== Foot steps configuration changed. ===== footSteps.foorStep ===== Foot step triggered. ====== Required Behaviors ====== This behavior requires no other behaviors. ====== 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_1ECBehaviorFootSteps.html,ECBehaviorFootSteps~@#. Since DragonScript Module Version ''1.0'' ====== Use Cases ====== * Play foot step sounds for actor when moving. ====== 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: second false second false value ====== Live Examples ====== * [[https://github.com/LordOfDragons/deexamples|DEExamples Repository]]