Dynamic footstep sounds with minimal input
1. We need two values only. We can define these two values inside our main character. We select our main character and add the value "underground = 0" to define the specific underground of our scene (or area) and the value "randomsound" to play the sounds randomly later.
2. And now we need a few scripts. For every type of underground we use in our adventure, we add one script inside our main character with names like "footsteps_sand" or "footsteps_wood". The type of these scripts should be "Called by other action". In these scripts we set our random variable "randomsound" to a random value between 1 and the number of sounds we have for that underground. In the next lines we play the corresponding sound to the current random value:
3. And now we need a script, that plays our sounds depending on the underground. We add a new script (type "Called by other action" again) with the name "footsteps". In this script we call the corresponding script to the current underground:
4. Now we have to trigger the "footsteps" script every time our character touches the ground. We go to the walk animation, select one of our "stomp to the ground" frames and add the script "footsteps" to the frame:
5. Now we are ready. The only thing we have to do is to set the value "underground" to the specific underground. There are many ways to do that. For example we can set the underground value to 0 (sand in this example) if we enter a beach scene or to 1 (wood) if we enter a wooden lodge. Or we use the walk-in action of an action area to change the underground value inside a scene locally.