Show / Hide Table of Contents

Interval Play

Several public APIs provided on FootstepSource belongs to Interval Play "mode".

Play the footsteps repeatedly on its own just by calling "start". You are able to call "update" to change how it sounds while playing as well, and finally you can call "stop" to shut it up. This mode has many advantages, including ease of use, optimization, and even features thanks to the fact that the library "knows the future".

API overview

This highlights the "start-update-stop" workflow of Interval Play, in that order.

StartInterval():void
StartInterval(ResolvingArgs resolvingArgs, TimingArgs timingArgs, StartArgs startArgs, ShotArgs shotArgs):void

UpdateIntervalResolvingArgs(ResolvingArgs resolvingArgs):void
UpdateIntervalShotArgs(ShotArgs shotArgs):void
UpdateIntervalTimingArgs(TimingArgs timingArgs):void

StopInterval(bool sudden):void

IsIntervalPlaying:bool

Start

You will mainly use the one with tons of arguments. A version without argument uses the Default Arguments instead. Everything was already explained in Getting Started/FootstepSource.

Update

They are splitted into 3 methods, each one updates the input argument you used on start.

This defines granularity of things you can update : The smallest update unit is each struct. When you call either of these methods, an entire struct is replaced with a new one.. For example, ResolvingArgs contains many things inside, and you must update everything together. You cannot update just Surface inside it without touching SurfaceModifier, Stepper, and StepperModifier.

Update will respect the step. It means your update will take effect on the next step, not affecting the current step that is lingering, and also the interval scheduling will continue as usual no matter how many time you spam update into it. This is desirable as often the update code could be rapidly called according to the game state without caring about footsteps. For example, player jugging movement key right on the seam between 2 different surfaces.

Stop

Stopping an interval has only one trick on it, which is the argument sudden.

"Sudden stop" means that not only that the scheduler running the steps is stopped, also the just-played step should also be abruptly cut off too.

By default, sudden is false. That means when stopping you will hear your latest step to its fullest. This is what the player expected to hear when they let go of the walk button.

sudden can be used for artistic purpose. Such as when the player is still holding down the walk button but now pressed jump. C# code must instruct Modular Footstep to stop the interval running walk sound before the character goes mid-air. In this case, sudden as true may sounds slightly more realistic.

Technical details

Efficiency

After calling start, a "scheduler" starts running and continue to check if it is at the right moment to play the next step or not every frame.

You may think of Unity's Coroutine, but it is even better here. Modular Footstep uses a singleton schedule planner for all FootstepSource in the scene. All start calls are gathered together into this singleton and it manages firing the steps for all sources in one update call.

Predictive features

There are features impossible to have in One-Shot Play. These feature requires the library knowing how long to wait until the next step (the interval), and so it can adjust that period of time dynamically to fix several niche problems :

  • Attack Calibration : Automatically move each step back in time differently in order to line up the impact peak inside the clip among variation members.
  • Footstep Lifts : Automatically insert lifting step audio in-between the down step interval. It requires no modification to the input interval you provided to the API call.

One running interval per source

A FootstepSource can only run one Interval Play. Calling Play while it is already playing will stop the previous play first, using sudden as true, before playing a new one.

You can check if an interval is already running on this source or not by checking on the getter property IsIntervalRunning.

You can still call One-Shot Play APIs even while an interval is running. The 2 modes use different state memories.

In This Article
Back to top
A Unity plugin by 5argon from Exceed7 Experiments. Problems/suggestions/contact : 5argon@exceed7.com Discord Unity Forum