Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Question Audio Clip played multiple times simultaniously

Discussion in 'Audio & Video' started by IrCilX, Feb 12, 2021.

  1. IrCilX

    IrCilX

    Joined:
    Oct 22, 2020
    Posts:
    2
  2. Jon_Olive

    Jon_Olive

    Joined:
    Sep 26, 2017
    Posts:
    23
    In the post you linked to - at least part of the problem is that a sound is being played if a key is down. That can of course be true for more than one frame - so each frame that the key is down (as well as the other conditions met) the sound will be re-triggered. You might want to check that you don't have something similar going on.

    Code (CSharp):
    1.         if(Input.GetKey(KeyCode.W) || Input.GetKey(KeyCode.Space))
    2.         {
    3.             if (canMove == true)
    4.             {
    5.                 if (isGrounded == true)
    6.                 {
    7.                     rb2D.AddForce(Vector2.up * jumpPower);
    8.                     PlaySound(playerJumpingSound);
    9.                 }
    10.             }
    11.         }