Hi everyone,
I need to create footsteps for a scene and so far have not been able to do so given the following constraints:
- I’m using the FPS controller (no character model);
- I need different footsteps sounds as per floor;
- Footsteps need to take velocity into consideration (more speed == more footsteps).
I have two different scripts for that. One controls which sounds to play (as from the 3rd person example):
SoundEffectControllerFloor.js
var footAudioSource : AudioSource;
var footsteps: AudioClip[];
function FootStrike () {
var volume = Mathf.Clamp01(Time.time);
footAudioSource.PlayOneShot(footsteps[Random.Range(0, footsteps.Length)], volume);
}
And the other is used to trigger those same sounds:
SoundEffectController.js
function OnTriggerEnter(collision : Collider) {
var som : SoundEffectControllerFloor = collision.gameObject.GetComponent(SoundEffectControllerFloor);
som.FootStrike();
}
The last one is not working, as I get no collisions between my FPS collider and the floor. Any clues?
I also know for a fact that the second code would not do exactly what I need (as in the beggining of the post). Some insights are much appreciated.
Thank you all in advance.