One-Shot Play
A few public APIs provided on FootstepSource
belongs to One-Shot Play "mode".
Upon calling the method, it plays exactly single footstep audio. This is a mode for tight and precise integration with animation or surface collision system, that you see other heavier solutions in the Asset Store providing. While flexible, this mode loses several great features in Interval Play as well.
API overview
Since there is nothing more to do other than listening to a single step sounding after the call, we have just these :
PlayOneShot():void
PlayOneShot(ResolvingArgs resolvingArgs, ShotArgs shotArgs):void
You will mainly use the one with arguments. A version without argument uses the Default Arguments instead. Everything was already explained in Getting Started/FootstepSource.
When to use it
Impacts on the surface
Even when you are mainly using Interval Play for walk and run, not everything is repeated in a loop. Your character may jump, slide, land, dash, or stomp on the same surface. If Modular Footstep only has Interval Play, you would have to implement those in good old AudioSource
PlayOneShot
.
Now you can use One-Shot Play to tackle those audio, while still use the same organized audio selection provided by Surface
+ SurfaceModifier
+ Stepper
+ StepperModifier
.
Also read about how Modular Footstep is more generic than you might think! The One-Shot Play is probably ideal for those applied usages.
Tight integration
You may not satisfied with Interval Play because it asks for fixed interval and play in a completely disjointed way from an actual animation.
You want to go an another level by playing the audio step-by-step right at the moment character's foot RigidBody
collides with a surface's collider, not by trying to indirectly sync with interval and start offset.
You may hook up those things to the One-Shot Play to take complete control of each step. However note that some great features exist only on Interval Play.
Technical details
The persistent state memory
This API may remind you of AudioSource
's PlayOneShot
. In the end it calls that anyways, but what's different is that consecutive One-Shot Play calls in Modular Footstep are connected.
When you use Interval Play combined with FootstepBehaviour
feature such as sequential picking, you expect it to be able to remember the current index in the sequence and know what is coming in the next play while the interval is playing.
The same in One-Shot Play, by calling PlayOneShot
3 times in a row while FootstepBehaviour
is set to sequential picking, you get the same expected sequential play. Other features like Random Exclusion is also depending on state memory because there is something to remember across plays.
This persistent state memory is maintained inside FootstepBehaviour
component. In Interval Play, this memory is reset on every new start call. In One-Shot Play there is no equivalent place to do so and the memory just keep going. (Called play using the same set of arguments or not.) If for some reason you want to force reset this memory, call ClearOneShotStateMemory
.