Footstep sounds with custom pawn [ Howard ]

Just a short update this time – Nothing I can really post without spoiling the upcoming content so I thought I would write a brief description of how the Footstep sounds in Dream work.
Normally in UDK you don’t have to worry so much about footsteps, you just tell the materials properties what audio clip to play, then it would play once a character walks on it.
This still works with a custom pawn, but once your pawn has a mesh you can instantly tell that the sounds don’t feel right when walking; The feet don’t sync up and running doesn’t speed up the sounds.

Fixing this was pretty simple – First off I needed to add “Notifiers” to all the animations. This lets us run a piece of code whenever a foot is placed on the ground.
Notify_1Notify_2

Next up, these few functions were added to the CustomPawn UC script which runs once the notifier that we set up earlier is triggered in the walking animations. Pretty simple instructions which gets the material Phys property and plays the sound below the foot.

simulated event PlayFootStepSound(int FootDown)
{

ActuallyPlayFootstepSound(FootDown);
return;

}
simulated function ActuallyPlayFootstepSound(int FootDown)
{
local SoundCue FootSound;

FootSound = SoundGroupClass.static.GetFootstepSound(FootDown, GetMaterialBelowFeet());
if (FootSound != None)
{
PlaySound(FootSound, false, true,,, true);
}
}

simulated function name GetMaterialBelowFeet()
{
local vector HitLocation, HitNormal;
local TraceHitInfo HitInfo;
local UTPhysicalMaterialProperty PhysicalProperty;
local actor HitActor;
local float TraceDist;

TraceDist = 1.5 * GetCollisionHeight();

HitActor = Trace(HitLocation, HitNormal, Location – TraceDist*vect(0,0,1), Location, false,, HitInfo, TRACEFLAG_PhysicsVolumes);
if ( WaterVolume(HitActor) != None )
{
return (Location.Z – HitLocation.Z < 0.33*TraceDist) ? ‘Water’ : ‘ShallowWater’;
}
if (HitInfo.PhysMaterial != None)
{
PhysicalProperty = UTPhysicalMaterialProperty(HitInfo.PhysMaterial.GetPhysicalMaterialProperty(class’UTPhysicalMaterialProperty’));
if (PhysicalProperty != None)
{
return PhysicalProperty.MaterialType;
}
}
return ”;

}

 

Next up, we create a sound class that has all the sounds that will play for certain materials that we walk over;

Class DreamSoundClass extends UTPawnSoundGroup;

 

defaultproperties

{
FootstepSounds[0]=(MaterialType=Sand,Sound=SoundCue’Dream_PhysMats_01.Sand.SandSteps_SC’)
FootstepSounds[1]=(MaterialType=IvyStone,Sound=SoundCue’Dream_PhysMats_01.IvyStoneSteps.IvySteps_SC’)
FootstepSounds[2]=(MaterialType=MazeStone,Sound=SoundCue’Dream_PhysMats_01.MazeStone.StoneSteps_SC’)
FootstepSounds[3]=(MaterialType=Metal,Sound=SoundCue’Dream_PhysMats_01.Metal.MetalSteps_SC’)
FootstepSounds[4]=(MaterialType=Rock,Sound=SoundCue’Dream_PhysMats_01.Rock.Rocksteps_SC’)
FootstepSounds[5]=(MaterialType=Wet,Sound=SoundCue’Dream_PhysMats_01.WetMazeStone.WetStoneSteps_SC’)
FootstepSounds[6]=(MaterialType=Grass,Sound=SoundCue’Dream_PhysMats_01.Grass.Grass_Footsteps’)
}

 

Then in the CustomPawn UC again. we add this class in the DefaultProperties;

SoundGroupClass = class’DreamSoundClass’

Now the hardest part is done really. You create a new Physical_material in the package you wrote above. For example for Grass I would make a new Phys_Mat called ‘Grass_Footsteps’ in my ‘DreamPhysMats_01.Grass’ package. Then its as simple as opening the mat, changing the settings then adding a ‘Physical Material Property’ and writing the ‘MaterialType’ we set earlier, so in this case- ‘Grass’

Phys_Mat_3

 

 

 

 

 

Then, on your Grass mesh simply add the Phys_Mat you just made:

4