Hi! There is a scene in my game that have water., and i wanted to make a script that add (or play) footstep sounds when my character walks in the water. Can someone help me? I have been trying to do this about a week for now and i didn’t get any result.
I wanted to make something like this:
The player is walking normaly in the map, making it’s default footstep sounds (it is a First Person Character). Then he enters in the water. EVERY TIME he walk, a sound is played. There are two different sounds, one for each foot.
The problem is that i don’t know how to make the sound repeat or something, and i don’t know how to get two sounds to play at the same time =
I am using JavaScript, but i would accept C# too.
Here’s my script:
#pragma strict
function OnTriggerEnter (o:Collider) {
//Below is the code to play the Audio Source attached to the Game Object (the water)
GetComponent.<AudioSource>().Play();
}
// The OnTriggerExit function is kinda disabled because i don't need to add anything on it.
function OnTriggerExit (o:Collider) {
}
This is a very simple Java-Script that play a sound attached to an audio source when the player hit the object’s collider. In my case, the object with this script will be the water. Can someone help me? I don’t have any idea to how to make this…