Search Unity

how to make an sliding sound effect?

Discussion in 'Editor & General Support' started by el-RERS, Aug 22, 2014.

  1. el-RERS

    el-RERS

    Joined:
    Jul 12, 2014
    Posts:
    9
    I have my character slide along a wall kind of like in megaman X and I want it to make an sliding sound effect, the problem is that I can't make it sound right, this is the code I'm using:

    1. publicAudioClip resbaladizo;
    2. voidAwake()
    3. {
    4. audio.clip = resbaladizo;
    5. }
    6. voidOnCollisionStay(Collision lacolision){
    7. if(lacolision.gameObject.tag =="Player"&&(lacolision.rigidbody.velocity.y<-5|| lacolision.rigidbody.velocity.y>5))
    8. {
    9. audio.Play();
    10. }}
    As expected, the sound clip sounds every frame the character is in the wall so the one-second sliding sound effect sounds terrible as it is being re-played every frame. Anybody has a good solution for this? Thanks in advance!