Quantcast
Channel: Latest Questions on Unity Answers
Viewing all articles
Browse latest Browse all 171066

Footsteps... Please Help

$
0
0
I am trying to create a js script that plays a random footstep sound when I'm on a particular surface, like gravel or metal, but everything I try doesn't work. I have searched the forums and not found anything. This is what I have already got. var WalkSoundInterval:float = 0.5; var FootstepsVolume:float = 0.5; var FootstepSoundsNormal:AudioClip[]; var FootstepSoundsGravel:AudioClip[]; var FootstepSoundMetal:AudioClip[]; InvokeRepeating("UpdateInterval",0,WalkSoundInterval); function UpdateInterval() { if(Input.GetKey("w")) { audio.clip = FootstepSoundsNormal[Random.Range(0,FootstepSoundsNormal.length)]; audio.volume = FootstepsVolume; audio.PlayOneShot(audio.clip); } } I have tried using the OnCollisionEnter to switch a boolean to true, but that didn't work and nothing else I try works. Please help. Thanks in advance.

Viewing all articles
Browse latest Browse all 171066

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>