Footstep sounds based on physical materials

Hey guys,

I’m working on a simple 1st person puzzle adventure game (somewhat like myst). Now I want to have different footstep sounds being played based on the surface the player is walking on. I have created some sound cues for different materials. Now…I looked at the FPS example project and noticed that the sounds have been assigned to the animations. That’s not the way I want to do it.
I have created physical materials for grass (PM_Grass), Concrete (PM_Concrete) and dirt (PM_Dirt) and the corresponding sound cues (SC_FS_Grass, …).
Can anyone give me some direction and/or a couple of code snippets? That would be awesome.
My project is based on the First Person project template (C++).
I’d be fine with blueprint, but to be honest…I like doing as much stuff in C++ as possible. I don’t want to have too much blueprint stuff around, as organizing and maintaining C++ code is a bit easier for me.

Thank you in advance :slight_smile:

I’d suggest still using the animations to determine the timings.
You do this by creating a custom animation notifier.
They are just Blueprints, based off the AnimNotify class.
From there, you can tell them to call a particular function - C++ or Blueprint - in your character.

If you don’t plan on having a mesh with animations that can do this, then you’ll have to fall back to the old method - do it in Tick().

Either way, the you will then need to use a trace to determine the material under foot.
You can get an example of doing this in the ShooterGame example.
Check out AShooterWeapon_Instant::SpawnImpactEffects() & AShooterWeapon::WeaponTrace() for starters.

Great - thanks! :slight_smile: Will have a look at it. I don’t have an animated mesh for the player, so I’ll do it the way you suggested (doing it in Tick() and using a trace).

By the way…your sig…rule #21…sounds like Palpatine to me :wink:

Thanks for helping me out.

No worries.
Oh, its not Palpatine - its Rules of Gunfight: Rule #21.