Post by scornflake on Apr 3, 2022 23:07:36 GMT
Helllooooo!
I'm trying to understand how MA networking audio works. (using MA2022 1.0.1, Unity 2020.3.31)
I've got a single MA setup in a scene. I'm using ParrelSync to run two copies of the game on the same host; and they are direct connection via Kcp.
All to say; I can run around with a couple of characters in game just fine.
Re MA setup:
The MAsterAudio component has got the Master Audio Multiplayer Adapter added to the MA gameobject.
NetworkIdentity is setup, and valid on the MA, like so (see 1st attachment)
This is what I get when I call the MAMA from code:
Trying to send command for object without authority. System.Void DarkTonic.MasterAudio.Multiplayer.MasterAudioMultiplayerAdapter::CmdPlaySoundAtTransform(System.String,System.UInt32,System.String,System.Single,System.Boolean,System.Single,System.Single,System.String)
UnityEngine.Debug:LogWarning (object)
Mirror.NetworkBehaviour:SendCommandInternal (string,Mirror.NetworkWriter,int,bool) (at Assets/Mirror/Runtime/NetworkBehaviour.cs:218)
DarkTonic.MasterAudio.Multiplayer.MasterAudioMultiplayerAdapter:CmdPlaySoundAtTransform (string,uint,string,single,bool,single,single,string)
DarkTonic.MasterAudio.Multiplayer.MasterAudioMultiplayerAdapter:PlaySoundAtTransform (string,bool,string,UnityEngine.Transform,single,System.Nullable`1<single>,single,string) (at Assets/Plugins/DarkTonic/MasterAudioMultiplayer/MasterAudioMultiplayerAdapter.cs:2872)
DarkTonic.MasterAudio.Multiplayer.MasterAudioMultiplayerAdapter:PlaySound3DAtTransform (string,UnityEngine.Transform,single,System.Nullable`1<single>,single,string) (at Assets/Plugins/DarkTonic/MasterAudioMultiplayer/MasterAudioMultiplayerAdapter.cs:259)
BeLibs.Environment.Audio.SoundSubstance:Footstep (UnityEngine.Transform) (at Assets/BeLibs/Environment/Audio/SoundSubstance.cs:39)
BeLibs.Environment.Audio.PlayerMovementSounds:PlayFootstepSound () (at Assets/BeLibs/Environment/Audio/PlayerMovementSounds.cs:337)
BeLibs.Environment.Audio.PlayerMovementSounds:PlaySoundsBasedOnState () (at Assets/BeLibs/Environment/Audio/PlayerMovementSounds.cs:267)
BeLibs.Environment.Audio.PlayerMovementSounds:Update () (at Assets/BeLibs/Environment/Audio/PlayerMovementSounds.cs:171)
The transform being passed in is valid, and I've verified that it's network id is authoritative.
So here what I don't understand:
MA's network adapter does this:
Instance.CmdPlaySoundAtTransform(sType, viewId.Value, transPath, volPercentage, useSpecificPitch, pitchVal, delaySoundTime, variationName);
Two things:
1) The network identity of "Instance" is *not* authoratitive. Accoring to mirror docs:
From my experience that means the object attempting to execute the [Command] on the server needs to be authoritative.
So I feel I'm missing something here. It seems like the MA network adapter is trying to send a server side Cmd, but will never be able to, because it (Instance), itself isn't authoratitive.
2) Even if it *could* send it, how does it make its way to other players?
For other players to hear the audio, doesn't a message have to be sent to those clients?
A [Command] by itself only sends a message to the server. And I see no code within the adapter than then broadcasts this out to all clients.
I figure this must all be tested and working, or I'm missing something really obvious, or my understanding of Mirror is very wrong.
Any tips / suggestions / help?
------------
What I had assumed should be happening as far as I understand Mirror:
1) Client sends message to server to say "play this audio". ([Command] attribute, client->server)
2) Server receives that message, and sends a RPC to all clients (excluding the owner, since it's already taken some action for that call locally). This'd be a Mirror ClientRpc attribute, e.g: [ClientRpc(includeOwner=false)].
unless im going nuts; what's missing is (2) above (well, that and getting the call to the server in the first place).
I'm trying to understand how MA networking audio works. (using MA2022 1.0.1, Unity 2020.3.31)
I've got a single MA setup in a scene. I'm using ParrelSync to run two copies of the game on the same host; and they are direct connection via Kcp.
All to say; I can run around with a couple of characters in game just fine.
Re MA setup:
The MAsterAudio component has got the Master Audio Multiplayer Adapter added to the MA gameobject.
NetworkIdentity is setup, and valid on the MA, like so (see 1st attachment)
This is what I get when I call the MAMA from code:
Trying to send command for object without authority. System.Void DarkTonic.MasterAudio.Multiplayer.MasterAudioMultiplayerAdapter::CmdPlaySoundAtTransform(System.String,System.UInt32,System.String,System.Single,System.Boolean,System.Single,System.Single,System.String)
UnityEngine.Debug:LogWarning (object)
Mirror.NetworkBehaviour:SendCommandInternal (string,Mirror.NetworkWriter,int,bool) (at Assets/Mirror/Runtime/NetworkBehaviour.cs:218)
DarkTonic.MasterAudio.Multiplayer.MasterAudioMultiplayerAdapter:CmdPlaySoundAtTransform (string,uint,string,single,bool,single,single,string)
DarkTonic.MasterAudio.Multiplayer.MasterAudioMultiplayerAdapter:PlaySoundAtTransform (string,bool,string,UnityEngine.Transform,single,System.Nullable`1<single>,single,string) (at Assets/Plugins/DarkTonic/MasterAudioMultiplayer/MasterAudioMultiplayerAdapter.cs:2872)
DarkTonic.MasterAudio.Multiplayer.MasterAudioMultiplayerAdapter:PlaySound3DAtTransform (string,UnityEngine.Transform,single,System.Nullable`1<single>,single,string) (at Assets/Plugins/DarkTonic/MasterAudioMultiplayer/MasterAudioMultiplayerAdapter.cs:259)
BeLibs.Environment.Audio.SoundSubstance:Footstep (UnityEngine.Transform) (at Assets/BeLibs/Environment/Audio/SoundSubstance.cs:39)
BeLibs.Environment.Audio.PlayerMovementSounds:PlayFootstepSound () (at Assets/BeLibs/Environment/Audio/PlayerMovementSounds.cs:337)
BeLibs.Environment.Audio.PlayerMovementSounds:PlaySoundsBasedOnState () (at Assets/BeLibs/Environment/Audio/PlayerMovementSounds.cs:267)
BeLibs.Environment.Audio.PlayerMovementSounds:Update () (at Assets/BeLibs/Environment/Audio/PlayerMovementSounds.cs:171)
The transform being passed in is valid, and I've verified that it's network id is authoritative.
So here what I don't understand:
MA's network adapter does this:
Instance.CmdPlaySoundAtTransform(sType, viewId.Value, transPath, volPercentage, useSpecificPitch, pitchVal, delaySoundTime, variationName);
Two things:
1) The network identity of "Instance" is *not* authoratitive. Accoring to mirror docs:
Commands are sent from player objects on the client to player objects on the server. For security, Commands can only be sent from YOUR player object by default, so you cannot control the objects of other players. You can bypass the authority check using [Command(requiresAuthority = false)]
From my experience that means the object attempting to execute the [Command] on the server needs to be authoritative.
So I feel I'm missing something here. It seems like the MA network adapter is trying to send a server side Cmd, but will never be able to, because it (Instance), itself isn't authoratitive.
2) Even if it *could* send it, how does it make its way to other players?
For other players to hear the audio, doesn't a message have to be sent to those clients?
A [Command] by itself only sends a message to the server. And I see no code within the adapter than then broadcasts this out to all clients.
I figure this must all be tested and working, or I'm missing something really obvious, or my understanding of Mirror is very wrong.
Any tips / suggestions / help?
------------
What I had assumed should be happening as far as I understand Mirror:
1) Client sends message to server to say "play this audio". ([Command] attribute, client->server)
2) Server receives that message, and sends a RPC to all clients (excluding the owner, since it's already taken some action for that call locally). This'd be a Mirror ClientRpc attribute, e.g: [ClientRpc(includeOwner=false)].
unless im going nuts; what's missing is (2) above (well, that and getting the call to the server in the first place).