Search Unity

Question Destroy GameObject without affecting AudioClip.

Discussion in 'Audio & Video' started by cxgenner, Jan 12, 2022.

  1. cxgenner

    cxgenner

    Joined:
    Jan 5, 2021
    Posts:
    3
    I'm very new to Unity and have stumbled on a small issue.
    I'm in the process of adding some sound files to a 2D game. I have collectible GameObject that needs to be destroyed when the player collides with it. Now everything works fine and I can play the sound, however when I add the "Destroy(gameObject);" line the sound is no longer heard in the game.

    How can I solve this?
    Thanks.
    upload_2022-1-12_13-24-3.png
     
  2. JLF

    JLF

    Joined:
    Feb 25, 2013
    Posts:
    139
  3. cxgenner

    cxgenner

    Joined:
    Jan 5, 2021
    Posts:
    3
    Great, I'm gonna give this a read and see if I can utilise this method. Thanks!
     
  4. cxgenner

    cxgenner

    Joined:
    Jan 5, 2021
    Posts:
    3
    This is great, I do have one small problem though.
    I wasn't sure if it was working at first because I couldn't hear anything amongst the other sounds. Once I muted all the other sounds, I could just about make out the sound of the PlayAtPoint clip.. I don't really understand why the volume is so low as I have all the default settings.

    *Fixed it*
    Thanks very much the help. Your blog post is very useful.
     
    Last edited: Jan 12, 2022