Trouble Triggering Footstep Sounds for different materials in Unity with FMOD
Hi everyone,
I'm facing a frustrating issue when trying to implement footstep sounds in my Unity project using FMOD. I've been scratching my head over this for a while, and I would really appreciate any insights or advice from the community.
I'm using animation events on my player character's animations to trigger a custom function called "PlayFootstep".
The "PlayFootstep" function calls an FMOD event that has a labeled parameter named "Terrain" to dynamically switch sounds based on the ground surface.
The Problem:
Even though the animation events seem to be firing correctly, the FMOD footstep sounds for different surfaces won't play consistently. Sometimes they do, when i jump mostly, sometimes they don't, and I can't find any discernible pattern. It seems that it is not reconizing the collision as it should.
What I've Already Tried:
Collider Checks: I've meticulously verified both player and ground object colliders. The player has a collider, and the ground objects have Mesh Colliders.
Layer Mask: The raycast in my script uses a LayerMask that includes the layer my ground objects are on.
FMOD Event Path:I've triple-checked the event path in my script. Everything seems correct.
Sound Parameter Setup: I'm confident that the "Terrain" parameter in my FMOD event is set up correctly.
Raycast Distance: I even experimented with increasing the raycast distance to ensure it was consistently reaching the ground.
Debugging: I've used Debug.Log statements to verify the script is working and calling the "PlayFootstep" function at the right moments, as well as identifying the object tags.
Any Ideas? I'll link the script and a demo video bellow. I'm not a programmer, and i'm fairly new to the technical side of audio design for games.
I'm at a bit of a loss and starting to suspect that there might be a subtle bug either in my project configuration or maybe in the interaction between Unity's animation events and FMOD.
Has anyone encountered something similar? Any troubleshooting tips, alternative approaches, or just general pointers would be incredibly helpful.
Here’s a folder with some screenshots and the script: https://drive.google.com/drive/folders/1TUX0qrBXwjKJ6REOjyEqL_NwEfw5bkBx?usp=sharing
Thanks in advance!