Hi there guys, quick question… Any tutorials or examples out there on how to add footstep sounds to… say the standard character contller? Or attached on an outside script would also work.
Characters definitely need footstep sounds ![]()
Hi there guys, quick question… Any tutorials or examples out there on how to add footstep sounds to… say the standard character contller? Or attached on an outside script would also work.
Characters definitely need footstep sounds ![]()
What i did was to add a animation event when the foot is grounded. You have to double the walk animation for that so that you can edit the animation. The original animation is usually not editable. The copy is. And then you need to apply the copy to the character too. And use this copy then for your walk animations.
Then add a script to the character to play the sound fx. You have to add the samples in the edtor:
Thats what i use here. Its a JS snippet. In the inspector you have to add :
var SFXstep_left: AudioClip; //here you drop your sound fx
var SFXstep_right: AudioClip; // here you drop your sound fx
var level : float = 0.5; // This is how loud the sound plays
function WalkSoundLeft(){
AudioSource.PlayClipAtPoint ( SFXstep_left, transform.position,level); //plays the sound when the function is called
}
function WalkSoundRight(){
AudioSource.PlayClipAtPoint ( SFXstep_right, transform.position,level); //plays the sound when the function is called
}
And when done you open the animation editor and add an animation event to call the two loops in this script here where the foot is grounded.
Hope the description makes sense to you ![]()
thank you! There’s also a very nice footstep controller in the bootcamp demo I totally forgot about. It’s based on the movement of the character controller, and even has different sounds for different physics materials.
well I can’t get the footstep sound controller from bootcampt to work anywhere outside of bootcamp…
public var footAudioSource : AudioSource;
public var woodSteps : AudioClip[];
public var metalSteps : AudioClip[];
public var concreteSteps : AudioClip[];
public var sandSteps : AudioClip[];
private var cc : CharacterController;
private var t : Transform;
public var hitLayer : LayerMask;
private var cTag : String;
function Start()
{
cc = GetComponent(CharacterController);
t = transform;
}
function OnFootStrike ()
{
if(Time.time < 0.5) return;
if(cc != null)
{
volume = Mathf.Clamp01(0.1 + cc.velocity.magnitude * 0.3);
}
else
{
volume = 1;
}
footAudioSource.PlayOneShot(GetAudio(), volume);
}
function GetAudio() : AudioClip
{
var hit : RaycastHit;
//Debug.DrawRay(t.position + new Vector3(0, 0.5, 0), -Vector3.up * 5.0);
if(Physics.Raycast(t.position + new Vector3(0, 0.5, 0), -Vector3.up, hit, Mathf.Infinity, hitLayer))
{
cTag = hit.collider.tag.ToLower();
}
if(cTag == "wood")
{
return woodSteps[Random.Range(0, woodSteps.length)];
}
else if(cTag == "metal")
{
return metalSteps[Random.Range(0, metalSteps.length)];
}
else if(cTag == "concrete")
{
volume = 0.8;
return concreteSteps[Random.Range(0, concreteSteps.length)];
}
else if(cTag == "dirt")
{
volume = 1.0;
return sandSteps[Random.Range(0, sandSteps.length)];
}
else if(cTag == "sand")
{
volume = 1.0;
return sandSteps[Random.Range(0, sandSteps.length)];
}
else
{
volume = 1.0;
return sandSteps[Random.Range(0, sandSteps.length)];
}
}
I just want a simple script… nothing complicated, i don’t need to be checking for animation events or physics events… i just want footstep sounds to be played if the character controller is moving.
that’s all. not looking for an advanced footstep sound controller. something simple will serve me well
Didn`t i already give such a simple script and method? I´m pretty sure i did.
well yes except for editing the animation and adding events to the footsteps. that’s not all that easy honestly. i copied the animation, and the copy is still not editable.
that and i don’t animate, and have never messed with it really.
and also. unknown identifier “movement”
is that the animation event I am to make… no idea how to do that.
Haha, didnt notice that the movement stuff was still inside. Just remove those lines. Thats a restriction for my own needs. I fixed the script above …
And my fault. My description wasn`t clear enough it seems. Someting that can easily be fixed too. I hope the following explanation is of use for you ![]()
And now it should call this function every time the animation is playing and reaches the point where you have added the animation event. In our case to play a sound effect.
Final step is of course to work with this edited walking animation now. The original walking animation doesn`t have this animation events.
Sorry for the wrong order of the pictures. I gave up at it …


