Built a procedural footstep system that detects surface materials at runtime - worth sharing my approach
Been working on a footstep audio system for my thirdperson game and finally got it to a place I'm happy with. Instead of manually tagging every surface, I'm using Physics.Raycast downward each step to sample the texture of whatever the character is standing on, then crossreferencing that against a ScriptableObject lookup table to pick the right audio clip set.
The cool part is it handles blended terrain textures too. I sample the dominant texture weight at the hit point and blend between two clip sets if the weights are close enough, so walking from grass onto gravel actually transitions naturally rather than snapping.
Performancewise it's pretty light. The raycast only fires on footstep animation events, not every frame, so it stays cheap even with a crowd of NPCs using the same system.
A few things I'm still figuring out: whether to bake surface data into a custom component on mesh colliders for nonterrain objects, or just rely on Physics Materials. I'm also debating whether a texturetosurface mapping approach scales well once the asset list grows.
Has anyone tackled something similar? Curious how others handle dynamic surface detection without making the inspector a nightmare to maintain. Always looking for cleaner ways to set this up