Closed jakemoves closed 6 years ago
That documentation link was misformatted, it should have the .md
at the end, sorry about that. Here's the correct link: https://placeholder-software.co.uk/dissonance/docs/Reference/Components/Dissonance-Comms. However that still doesn't directly answer your question!
As the error message says, you can't change the player name once the DissonanceComms component has been started (i.e. the Unity MonoBehaviour.Start method has been called). So if you really want to set this to a custom value you'd need to have it in the scene but disabled, set the LocalPlayerName
property and then enable it.
DissonanceComms comms; //In scene, but not enabled
comms.LocalPlayerName = "A Name";
comms.enabled = true;
However this isn't ideal because the player can't changed their name without leaving the session, destroying the DissonanceComms components, creating entirely new ones and then rejoining the session. To be honest I think this is a poorly named property - rather than considering this a human readable name you should think of it as an ID used by Dissonance. Then you can layer your own names on top of this (and Dissonance continues to use it's default IDs internally).
I'll close this issue since I've answered the question, but feel free to ask followup questions if it's not clear :)
Thank you! Yes, it wasn’t really clear that it was a basically immutable ID. So there are definitely better ways to do what I’m trying to do :)
On Nov 13, 2017, at 9:19 AM, Martin Evans notifications@github.com wrote:
That documentation link was misformatted, it should have the .md at the end, sorry about that. Here's the correct link: https://placeholder-software.co.uk/dissonance/docs/Reference/Components/Dissonance-Comms. However that still doesn't directly answer your question!
As the error message says, you can't change the player name once the DissonanceComms component has been started (i.e. the Unity MonoBehaviour.Start method has been called). So if you really want to set this to a custom value you'd need to have it in the scene but disabled, set the LocalPlayerName property and then enable it.
DissonanceComms comms; //In scene, but not enabled comms.LocalPlayerName = "A Name"; comms.enabled = true; However this isn't ideal because the player can't changed their name without leaving the session, destroying the DissonanceComms components, creating entirely new ones and then rejoining the session. To be honest I think this is a poorly named property - rather than considering this a human readable name you should think of it as an ID used by Dissonance. Then you can layer your own names on top of this (and Dissonance continues to use it's default IDs internally).
I'll close this issue since I've answered the question, but feel free to ask followup questions if it's not clear :)
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or mute the thread.
Context
I'm trying to set LocalPlayerName so clients can set a handle (name).
Expected Behavior
I'd expect to be able to assign this variable a value.
Actual Behavior
When I do this in a script in my scene with code like:
I get the error:
The documentation links are out of date, and it's not clear to me when I can set the PlayerName and how.
Your Environment
Dissonance version used: e.g. v3.0.3
Unity version: 2017.1