I placed an if statement in OnCollisionEnter that plays the audio clip only when the timer is less than or equal to zero, and then sets the time back to the cool down amount after being played. In the player controller script I placed an if statement in Update as seen on the left, this subtracts from the timer while it is above zero. To avoid the audio to be played a hundred times a second I made a cool down for the clip. Even though the base functionality and concept is there, it needs some tweaking. I made the volume equal the players veolicty magnitude, this means that the faster the player is travelling the louder the impact. The collision sounds are placed in an array and then when called I use the Random.Range function in the index of the array with a minimum value of 0 and a maximum of 1. Because I had multiple hit sounds, when the sound is called in the script a random number is generated to decide which audio clip to play.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |