I don't want to hear other persons when the audio source distance is out of scope.

Options
harlan
harlan
edited July 2019 in Photon Voice
Hi @JohnTube

I change the audio source configurations using the following codes and try to shrink the voice distance to 1 meter in the virtual world:
     private void OnEnable()
        {
            speaker = target as Speaker;
            audioSource = speaker.GetComponent<AudioSource>();
            audioSource.rolloffMode = AudioRolloffMode.Linear;
            audioSource.maxDistance = 1;
            audioSource.minDistance = 0;
            audioSource.spread = 0;
            audioSource.dopplerLevel = 0;
            playDelayMsSp = serializedObject.FindProperty("PlayDelayMs");
        }
Questions 1:

I found that the audio source configurations is not transferred to photon server, and restore this configurations in the clone prefab,, the locally Instantiate prefab and the clone prefab all use the same default values?Is that right?So I can change the above codes and let all the Instantiate prefabs use the same conf values.

Question2 ::
there are two persons in the virtual world whose audio source max distance are all 1, the effect I want to get is when one person is out of another person's audio source scope, they cannot hear each other.But now the result is we can hear each other, only the volume is smaller and smaller when our distance is further and further.When the distance is reach to 30-40, we can not hear other.So what's wrong with my codes?Or How can I reach the effect??

Thanks.

Comments

  • JohnTube
    JohnTube ✭✭✭✭✭
    edited July 2019
    Options
    Hi @harlan,

    Answer 1:
    I found that the audio source configurations is not transferred to photon server, and restore this configurations in the clone prefab,, the locally Instantiate prefab and the clone prefab all use the same default values?Is that right?So I can change the above codes and let all the Instantiate prefabs use the same conf values.
    Yes we do not sync those. If you add an AudioSource component to the same GameObject as the Speaker, it will be used as is in all instantiated GameObjects.

    However, I would not modify Photon Voice code and do the configuration from the scene and into the prefab directly. Otherwise, you will have to be careful when you update Photon Voice to not overwrite your changes.

    Answer 2:
    This is rather a question for Unity and depends on the audio setup of the scene and components.