Biography: |
To play sounds through one of these groups, we simply create Audio Sources with the Output field configured to the right AudioMixer group. In the Player script, add a private variable of type AudioClip named “_laserClip” with a null value this is a reference for the sound effect that will play. Then create a private variable of type AudioSource named “_source” with a null value this is a reference to the Audio Source component on the Player that is told to play the laser sound. Again this way we can easily add a new tilemap and if we put on it the StepSoundData script and assign to it the AudioClips the previously written system will work with it. It’s much better than having “if-else if” block where you check for each type of terrain to select the specific AudioClip for it. |