Search Unity

Audio Urgent help needed: Two Game Objects, two Audio Sources, only one is played on both

Discussion in 'Audio & Video' started by Whizzkid78, Jan 19, 2020.

  1. Whizzkid78

    Whizzkid78

    Joined:
    Oct 26, 2018
    Posts:
    1
    Hey guys and gals, I am very new to Unity and programming and so far I have everything up and running on my little Game Project for uni. But I am having one problem I am unable to solve or find answers for on the internet:

    I have two different game objects set up with individual Audio Sources and have set up a script which allows me to drag and drop audio files to meet certain criteria. That works absolutely fine and the mechanics on how to trigger the different sounds as well. I have applied the same script to the two different Game Objects, as one does and changed the audio clips accordingly to match the Game Objects. The thing is: ONLY the sounds from the first Game Object are played (again correctly according to the game mechanics) on both different Game Objects. I even placed the Player Character close to the second Game Object, so I don't need to interact with the first one. Same thing: Interacting with the second Game Object plays the sounds of the first. When I destroyed the first Game Object the console told me on the second one, that the Audio Source was destroyed (I temporarily circumvented that by not destroying the object but just the Rigidbody2D). Problem stays the same, that Game Object two is referencing the Audio Source from GO 1.
    I deleted and applied the Audio Source components anew and individually several times to be sure.

    I am not sure, what I am doing wrong here and am not sure that it actually is something in the code, or?
    I am at a loss and would greatly appreciate some feedback and am looking forward to your constructive replies. Many thanks in advance.