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

Audio Audio Source problem

Discussion in 'Audio & Video' started by DevM22, Aug 25, 2020.

  1. DevM22

    DevM22

    Joined:
    Aug 10, 2019
    Posts:
    14
    It seems I have a problem where two objects each with an audio source are playing both of their sounds only from one of the objects that has one of those audio sources and I can't wrap my mind on how it is happening.
    Object 1 where the footsteps is where the audiosource is located
    upload_2020-8-25_1-22-51.png
    Object 2 where the footsteps is where the audiosource is located
    upload_2020-8-25_1-23-36.png
    Object 1 script settings( script basically messes with the audio source settings since it seems that changing it through the editor in unity wasn't working not sure why so I did it with code)
    upload_2020-8-25_1-25-9.png
    Object 2 script settings
    upload_2020-8-25_1-24-7.png

    code of the said script:
    upload_2020-8-25_1-25-51.png


    So if I mute the audio source on object 2 absolutely nothing happens in terms of stop hearing the sounds its making, however muting object 1, mutes both sounds. The only explanation I have is that the script is somehow getting the same audio source but shouldn't get component get the audio source within the same object?
     
  2. DevM22

    DevM22

    Joined:
    Aug 10, 2019
    Posts:
    14
    Extra quick question:
    If I want to achieve this lighting effect is it better to add lighting to the prefabs (walls/floor) or add new gameobjects with the light component and move them around?
    upload_2020-8-25_1-30-27.png