Footsteps by surface¶
Level designer · 30 min · No code
Result: characters walking on your new ground type, here snow, play a snow step sound and a puff of snow, and the old grass and stone surfaces keep theirs.
Before you start¶
- A step sound (Sound Wave, Sound Cue or MetaSound) and optionally a small Niagara effect for the new surface.
- Build a world-partition map if you are making a new map.
How a footstep picks its sound¶
Five links, each set in a different place. A footstep plays only when all five agree.
| # | Link | Where | Sample |
|---|---|---|---|
| 1 | The animation marks each step | Anim notifies on the walk and run clips send AnimEffect.Footstep.Walk (and AnimEffect.Footstep.Land on landing) |
already set up |
| 2 | The ground says what it is | A physical material with a Surface Type | Environment/PM_XenoCore_Grass = Grass |
| 3 | The surface type has a name | Project Settings › Physics › Physical Surface | SurfaceType4 = Grass |
| 4 | The name becomes a gameplay tag | Project Settings › LyraContextEffects › Surface Type To Context Map | SurfaceType4 → SurfaceType.Grass |
| 5 | The tag picks the effect | A context effects library row: effect tag + context tag → sounds and Niagara | ContextEffects/CFX_XenoCore |
The character's Lyra Context Effect component traces the ground under the foot, reads its
physical material, turns the surface into a tag, and plays whatever the library lists for
that step tag + that surface tag. The party pawns use CFX_XenoCore.
Ground with no physical material resolves to SurfaceType.Default, which plays the concrete
step.
Steps¶
1. Add the surface type¶
- Project Settings › Engine › Physics, section Physical Surface.
- Fill the next free slot (the shipped project uses 1 to 4; the XenoCore project setup (Install) adds slot 4,
Grass, to a buyer's project) with the nameSnow. Note the slot number, for exampleSurfaceType5.
2. Add the tag¶
- Project Settings › Project › Gameplay Tags. Click Add New Gameplay Tag.
- Name it
SurfaceType.Snowand set Source toDefaultGameplayTags.ini(the project's own tag list), not a plugin's tag file. Click Add New Tag.
Keep surface tags in the project's own tag list
The surface-to-tag map is read very early, when the game's settings load. A tag defined in a plugin's tag file may not exist yet at that moment, so the mapping silently points at nothing and the surface falls back to the default step.
3. Map the surface type to the tag¶
- Project Settings › Game › LyraContextEffects.
- In Surface Type To Context Map, add
SurfaceType5(it shows as Snow) →SurfaceType.Snow.
4. Make the physical material¶
- In the Content Browser, open
MyGame/Environment, right-click, and choose Physics › Physical Material (class PhysicalMaterial). Name itPM_Snow. - Set its Surface Type to Snow.
5. Put it on the ground¶
Choose the one that matches your ground:
- A landscape: select the Landscape actor and set Default Phys Material to
PM_Snow. That covers the whole landscape unless its material outputs a physical material per paint layer. - A material used by meshes: open the material and set Phys Material in its Details.
- One static mesh: open it in the Static Mesh editor and set Collision › Simple Collision Physical Material.
Fails silently: a landscape with no physical material sounds like concrete
A landscape without Default Phys Material resolves every step to the default surface, which is mapped to the concrete sound. Nothing warns. Any new map's landscape needs this field.
6. Add the effect rows¶
Rather than editing XenoCore's library, give the characters a library of your own:
- In the Content Browser, open
MyGame/Audio, right-click, and choose Data › Data Asset. Pick the class Lyra Context Effects Library and name itCFX_MyGame. -
Add two entries to Context Effects:
Effect Tag Context Effects AnimEffect.Footstep.WalkSurfaceType.Snowyour step sound, your Niagara puff AnimEffect.Footstep.LandSurfaceType.Snowyour landing sound -
Add
CFX_MyGameto the characters. OpenGame/B_XenoCore_PlayableCharacter_BaseandCharacters/Party/B_XenoCore_PartyMember_Base. On each, select the LyraContextEffect component and addCFX_MyGameto Default Context Effects Libraries. Compile and Save both.
Both pawn bases need it: the player's pawn and the party members are built on different bases.
The VRoid party members (Characters/VRoid/B_XenoCore_Party_VRoid_Base and its children) are
children of B_XenoCore_PartyMember_Base, so they inherit it. (On the party base the
LyraContextEffect component comes from its C++ parent, so it shows as inherited; the library
list you set on the Blueprint is still what the members use.) Libraries add up rather than one
winning: a step plays every matching row from every library in the list.
Or add rows to CFX_XenoCore
Adding the two rows to ContextEffects/CFX_XenoCore also works and touches one asset instead
of three. It is a shipped asset, so a template update may overwrite it.
Test it¶
- Place a flat mesh or paint an area that uses
PM_SnowinMaps/L_XenoCore_Gymor your map. - Play and walk from the normal floor onto it. The step sound changes to yours, and your puff appears under each foot.
- Jump and land on it. The landing sound is yours.
- Walk back onto grass or stone. Their sounds are unchanged.
If it doesn't work¶
Still the concrete step
The ground has no physical material, or the physical material's Surface Type is still Default. Check the landscape's Default Phys Material first.
Silence on the new surface
The surface resolved to SurfaceType.Snow, but no library row matches. Check the row's
Effect Tag is exactly AnimEffect.Footstep.Walk and its Context is exactly
SurfaceType.Snow, and that CFX_MyGame is on the pawn you are playing.
Works for the leader, not for party members
The library is on only one of the two pawn bases.
Going further¶
- Build a world-partition map
- Animation: where the footstep notifies sit in the clips.