Footsteps are a staple part of game audio. Whether just simple noisy blips or complex interactive systems, these sounds can ground a player in a game. In many of these games, character movement is the most persistent form of interaction the player has with the game world. This fact makes it an important system to get right, so let’s have a look at tackling this topic.
In this blog, we will create a dynamic system that will play relative to the character’s movement speed and reflect changes in surface interaction. The result will mean sauntering across metal should sound very different from running across wood.
This project was created using CRI Atom Craft Ver.3.43.09 and UE4.24.3
Walking is made up of two distinct impacts, a stomp of the heel, and a slap of the forefoot/toes. Generally speaking, the faster a person moves, the shorter the time between these two impacts. We can recreate this process in Atom Craft by using separate Cues for each and sequencing them in our game engine. This approach has the added benefit of allowing for more random variation. To create our system, we will need to create:
- A Selector and name it “Footstep_Surface”
- Create 3 Selector Labels named
- Create 3 Selector Labels named
- A Random No Repeat Cue for each heel and toe surface type
- Named appropriately (“Gravel_Heel,” “Gravel_Toe,” “Metal_Heel” etc.)
- Two Polyphonic Cues, named “Footstep_Heel” and “Footstep_Toe”
- Link all Random No Repeat Cues to their respective Polyphonic Cues
To play our heel-toe components in UE4, we will trigger them separately, and control the offset in the game engine. However, to test the heel-toe components as one footstep in Atom Craft, we can create a temporary Cue and manually offset them in the Timeline.
[Note] To avoid clutter in our UE4 project, we can place the heel-toe components in a Private Cue Folder.
To implement our audio, we can use the Third Person Blueprints template that UE4 provides. As usual, the documentation is the best place to start if you need help getting the CRIWARE SDK integrated, and the CueSheet Binary imported.
To determine what surface our character is walking on, we can make use of UE4’s Physics Material feature. To set this up, we first need to select Edit → Project Settings → Engine → Physics and scroll to the bottom.
Under Physical Surface, we can create surface types for each the Selector Labels we defined in Atom Craft: “Gravel,” “Metal,” and “Wood.” Next, in the Content Browser, right-click, and select Physics → Physics Material. Then, create a new Physics Material for each of the above Physical Surfaces, and name them accordingly.
Open each Physics Material and under Physical Properties, set the Surface Type to match to the Physical Surface created in the Project Settings menu.
Next, we can create some Planes to test each of our surfaces. To assign our Physics Materials, we can drag from the Content Browser onto Phy Material Override under the Collision heading in the details panel while the appropriate Actor is selected.
We can control the heel-toe playback via different methods. One of the simplest is to scrub through the Timeline of our walking Animation manually, and right-click on the Notifies timeline → Add Notify → PlayAtomCue when the heel lands, then again when the toes land. Let’s go ahead and do this for both the ThirdPersonRun and ThirdPersonWalk animations, which can be found under Content → Mannequin → Animations. A Blend Space controls the transition between idle, walking, and running states. If sounds are triggering erroneously, ensure that Notify Trigger Mode is set to “Highest Weighted Animation” in the Asset Details panel on the Blend Space asset.
We also need to ensure the correct sound plays for each. To do this, we need to highlight each Anim Notify and select the right sound from the dropdown in the Details panel.
Playing the game now should subtly reflect the difference in movement speed. However, we need one last piece of code to control the playback relative to surface type. Let’s open the ThirdPersonCharacter Blueprint and navigate to the “Movement input” section of the Blueprint. To check the surface below the character, we can do a simple LineTraceByChannel directly down from the character.
The above code is run just after adding the player’s input to the character’s Add Movement Input. This code will GetActorLocation from the character (self) to determine the Start point and calculate a line straight down to get the End point.
We can finally Get Surface Type from the Out Hit of the line trace and use Select to output the correct String based on what was hit. Since we named our Physical Surfaces in UE4 the same as our Selector Labels in Atom Craft, we can type strings that match the inputs. We can also determine what sound should play if a surface doesn’t have a Physics Material attached by setting a Selector Label for the Default input.