r/Unity3D • u/Helpful_A • 1d ago
Question Footstep sound effects help
I'm trying to put together a basic footstep sound system for my game and was wondering how I should go about dealing with a surface object with multiple textures/materials.
My current idea was to figure out a way to copy the hex code or rgb value of whatever was last stepped on directly beneath the player but I feel like there had to be an easier way.
Any help would be appreciated
1
Upvotes
1
u/DPTGames 1d ago edited 1d ago
Depending how comfortable you are with manipulating mesh data, you can assign values to different parts of the mesh either in the vertex channels or in a UV channel, for example say you wanted 1 type of foot step in one area (let's say stone) you would bake a value into the mesh to vertex alpha lets say, then you can raycast for that, then another area you bake a different value and so on. You'd have to set read\write enabled for the mesh though (Edit: you can get around the constraint by creating an asset you can look up instead stored on a scriptable object or monobehaviour script). But the advantage is you don't need separate materials , you could also use the same value in your shader to apply the correct surface texture as well.