how to make a surface detector (for footsteps) 3d

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Dylised

i want to make a game that has multiple floorings; tiles, concrete, wood, carpet
and have different sounds on what i walk on.

:bust_in_silhouette: Reply From: stormreaver

I haven’t actually done it myself, so this is more of a stream-of-consciousness reply.

I would approach this by embedding the walking sound into the scene class that represents each flooring. Have a raycast emitted from the player downward towards the floor. When the raycast indicates a collision with the floor, get the collision object (which will be the floor’s scene object) which will contain the walking sound to play, and play it.