View Full Version : 3D Voice in Unity SDK not working

May 19th, 2016, 07:49 PM
I am setting TeamSpeakClient.SystemSet3DListenerAttributes for the current user and TeamSpeakClient.ChannelSet3DAttributes for multiple users as well as adjusting the distance and rollOffScale settings with TeamSpeakClient.SystemSet3DSettings, but nothing I change seems to spatialize the voice.

I think the issue lies in the TeamSpeakInterface class passing the TS3_VECTOR objects to the dll.
ts3client_systemset3DListenerAttributes for example uses the out keyword to pass the variable to the dll, I don't see how this can work. It should be using the ref keyword, but there are likely some other Marshalling issues as well, since I tried to just make that change.

If you try to use a value passed to a function with the out keyword, it won't compile in C# (Use of unassigned out parameter Error). out is for returning data, ref is to pass a value by reference.

Please let me know if I'm missing something, would love to get 3D voice working!

Thank you for your time.

May 20th, 2016, 08:18 AM
Looks wrong to me, too.
While there's a new C# wrapper in development, let's try to fix it right here as I don't have an ETA on that.

Shot from the hip I'd change:

public struct TS3_VECTOR
public float x;
public float y;
public float z;

[DllImport(DLL_PATH, EntryPoint = "ts3client_systemset3DListenerAttributes")]
public static extern uint ts3client_systemset3DListenerAttributes(uint64 scHandlerID, [param: MarshalAs(UnmanagedType.Struct), In] ref TS3_VECTOR position, [param: MarshalAs(UnmanagedType.Struct), In] ref TS3_VECTOR forward, [MarshalAs(UnmanagedType.Struct), In] ref TS3_VECTOR up);

[DllImport(DLL_PATH, EntryPoint = "ts3client_channelset3DAttributes")]
public static extern uint ts3client_channelset3DAttributes(uint64 scHandlerID, anyID clientID, [param: MarshalAs(UnmanagedType.Struct), In] ref TS3_VECTOR position);

That said, it's untested and I haven't been working in C# for quite a while. I'll point our dev in charge for C# / Unity here, too.

March 24th, 2017, 08:15 AM
Forgive the necromancy here, but I've just run into the same issue. I've tried the hack suggested by thorwe, but it had no impact on the audio whatsoever; there's neither distance attenuation nor directionality to the sound.

Any ideas, and/or updates on the "new C# wrapper" that was mentioned back in May?

April 11th, 2017, 04:20 PM
Did you find solution of this problem? If yes, please share it.