• Author
    Posts
  • #2152

    Chrisu
    Participant

    Hi,

    I’m trying to create a multiplayer (2 players) game, in which every player has a pair of headphones.
    Each player should hear the sound like received at their position/transform.

    Could that maybe be done using two RealSpace3D AudioListener objects, which each generate sound from different positions for each player?
    One listener could then output audio to the (default) front left/right speaker port, and the other one to one of the surround output ports, like rear left/right speakers (both these ports would have a stereo headset/headphones connected).

    This would be an awesome addition to the RealSpace3D plugin.

    Cheers,
    Chrisu

    • This topic was modified 1 year ago by  Chrisu.
    • This topic was modified 1 year ago by  Chrisu.
  • #2155

    Rod_RealSpace3D
    Keymaster

    Hello Chrisu,

    The RS3D AudioListener does no processing, it is only used for selecting HRTFs (Head Related Transfer Function) data set and head, neck, torso params. Unity’s AudioListener is still processing and must be in the scene. Unity doesn’t allow for multiple AudioListeners in a scene (2+ AudioListeners will be ignored and you will receive warning messages in the console window). However, in your application you can write a script (I haven’t tried this but should work…when I get some free cycles (hmmmnnn…when will that be 😉 ) I will give it a try) that checks if the network view is yours…

    (Sorry about formatting)

    private Camera theCamera;

    void Init()
    {
    theCamera = Camera.main;
    }

    void Start()
    {
    if(networkView.isMine)
    {
    theCamera.active = true;
    theCamera.GetComponent(AudioListener).enabled = true;
    }
    else
    {
    GetComponent(MouseLook).enabled = false;
    theCamera.active = false;
    theCamera.GetComponent(AudioListener).enabled = false;
    }

    Something like that should work.

    /Rod

You must be logged in to reply to this topic.