- Home /
 
               Question by 
               knuckles209cp · Dec 11, 2013 at 06:44 AM · 
                collideraudiosoundfoot  
              
 
              Sound not working?
I am VERY stuck on this , so i want to play a foot sound when i go over the collider , but this comes up : No appropriate version of 'UnityEngine.AudioSource.Play' for the argument list '(UnityEngine.AudioClip)' was found.
The script
 #pragma strict
 
 private var footsteps : PlayerFootsteps;
 private var footSound : AudioClip;
 
 function Start()
 {
     footsteps = GameObject.Find("First Person Controller").GetComponent(PlayerFootsteps);
 }
 
 function OnTriggerEnter (Col : Collider)
 {
     if(Col.gameObject.tag == "Player")
     {
         footsteps.inWater = true;
         audio.Play(footSound);
     }
 }
 
 function OnTriggerExit (Col : Collider)
 {
     if(Col.gameObject.tag == "Player")
     {
         footsteps.inWater = false;
         audio.Stop(footSound);
     }
 }
               Comment
              
 
               
               
               Best Answer 
              
 
              Answer by tanoshimi · Dec 11, 2013 at 07:12 AM
Like the error message says, you don't pass an AudioClip parameter to the Play() method. You set the clip, then call Play(), as shown in the docs.
For a footstep sound, however, I think you simply want to replace:
 audio.Play(footSound);
with
 audio.PlayOneShot(footSound);
Your answer
 
 
              koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                