DEV505 / SOUND LAB / 02
Every step counts.
One footfall. Three surfaces. Many trimmed variations.
Try it in Unity
Section titled “Try it in Unity”In Unity’s Project window, open Assets/DEV505/SoundManager/Samples/02-Footstep/Demo.unity. The supplied scene already has its Sound Manager, event registrations, generated keys, camera, and Audio Listener. Press Play, wait for the demo to be ready, and click the Game view before using the keyboard. If you are setting up a separate scene, follow Your first sound first.
| Control | Action |
|---|---|
| WASD / arrow keys | Walk across the island. |
| Left Shift while moving | Sprint; steps happen more often as you cover ground faster. |
Walk over grass, then cross the stone and wooden areas. Listen for a change in texture at the next footfall: soft grass, harder stone, and hollow wood. Stop moving; footsteps stop too. The controller measures distance travelled while grounded. It does not play a loop while a movement key is held.
The listener is already configured in the scene. This particular Footstep event is currently 2D, so its surface choice changes the sound without distance fading or left/right placement. The contact position is still passed in the context; it becomes useful if you change the event to 3D for your own game.
From a footfall to a sound
Section titled “From a footfall to a sound”FootstepPlayer detects grounded movement and reports a contact point and a surface. FootstepAudio translates that surface to the graph’s integer and makes one play request. These two sets of numbers differ:
| Ground detected by the scene | Scene enum | Graph Surface |
|---|---|---|
| Unknown | 0 | Skip the sound. |
| Grass | 1 | 0 |
| Stone | 2 | 1 |
| Wood | 3 | 2 |
Casting the scene enum directly would select the wrong branch. The complete recipe uses an explicit switch and ignores unknown ground.
var context = SoundPlayContext.At(contactPosition) .With(SoundParameters.Footstep.Surface, 0);var result = SoundBus.Play(Sounds.Footstep, context);Here contactPosition is the position supplied by your ground check. 0 is an Int, matching the graph. 0f is a Float and would be the wrong type. Put this value in the initial context: the graph selects the recording as the play begins, so changing Surface afterward is too late for that step.
Read the graph
Section titled “Read the graph”Each surface has a named group containing four Wave Assets and a Random Clip node. The four entries can point to the same long recording but use different start times and lengths. Random Clip chooses a variation with immediate repetition disabled. Surface selects between the three groups; On Start triggers one Play Audio node. Its Finished output reaches End Event, so the short play cleans itself up.
Random choice is part of the graph. The choice history for Random Clip is managed by the service, allowing successive footstep requests to avoid immediately repeating that choice. This does not make the order a fixed playlist or guarantee that every recording plays once before any repeats.
Trim one footfall from a long recording
Section titled “Trim one footfall from a long recording”Open the Footstep graph and select a Wave Asset inside a surface group. The compact node shows Asset, Start, and Length. Expand Range at the bottom of the node to preview the waveform and select the part containing one step. In the shown example, Start is 1.100 s and Length is 0.530 s, so playback ends at 1.630 s. Length is a duration, not an end time.
Move the selection to a clean attack and let the short tail finish. Repeat for the other entries, using a different footfall each time. The source recording stays intact; each Wave Asset stores its own trim. If the waveform is hidden, expand Range again. Start and Length remain available even when that section is collapsed.
The capture library also shows the matching Stone and Wood groups. Keep the same structure when adding more surfaces: variations first, then the surface selector, then one playback path.
What belongs to the demo?
Section titled “What belongs to the demo?”The sound graph handles trim ranges, variation, surface selection, and the end of each play. Player movement, ground detection, stride spacing, the glowing face, and HUD labels belong to the sample’s C# and scene setup. Sound Manager does not detect what your character is standing on.
Common surprises
Section titled “Common surprises”- A whole walking recording plays. Check Start and Length on every variation; assigning the asset alone does not find individual steps.
- Stone sounds like wood. Check the explicit enum mapping above.
- Steps play while standing still. Trigger at a footfall, not every Update. For an animated character, an animation contact event can call your own step method.
- Moving the emitter makes no audible difference. This saved graph is 2D. Use the Bee demo to hear spatial placement.
- Overlapping steps disappear under heavy traffic. The event allows eight overlapping plays and replaces its oldest at the limit. The normal demo does not need an endless loop or a retained handle for each step.
Event settings, parameters, and signals
Section titled “Event settings, parameters, and signals”These are the saved graph settings. A play can supply different initial parameter values. Float smoothing is measured in units per second; a rate of 0 applies changes immediately.
Sounds.Footstep
- Position
- 2D
- Overlapping plays
- 8 ·
ReplaceOldest - Cooldown
- None
- Owner loss
- Stop
- Keep Alive
- Off — ends when its work is finished
| Parameter | Type | Default | Range | Rise / fall rate |
|---|---|---|---|---|
Surface | Int | 0 | 0–2 | Not smoothed |
Signals: None authored.
For the meaning of these settings, see Playback settings. The default numbers above come from the Unity graph audit stored with this documentation.
Take it into your own game
Section titled “Take it into your own game”Open the complete integration recipe for the script, Inspector setup, a short test, and cleanup. Use Play context for initial values and placement, and SoundBus for playback controls.
All Footstep Unity captures includes further states and readable graph details, with steps to reproduce each view.