Hello everyone.
I’m new to using Mirror. I’ve tried following several guides, and have a scenario that I still can’t figure out. I’m not even sure how to properly word my question / highlight my issue, sorry in advance.
I am basically just sending a Random number, that I want both players to be able to view. The Server+Client window is correctly updating a shared screen text / UI element, but the Client only window is not updating that same shared text properly.
The Server+Client player (Player303, in the top image here) has rolled a 4 and a 12. Both upper text elements update properly on both screens (bottom screen shows 'Player303 4 12, as expected) so both players can see the “Player303 4 & 12”
However, when player 2 (Player 116, who is in control of the bottom here) clicks their random button… it properly updates their OWN UI (to show the 5 and 1) but the SHARED text just above it, shows an invalid value of 6 and 6.
It is defaulting to the hard coded static float variables within the script itself, but only for the ‘shared’ text element. The non-shared, my-window-only text, does get updated as needed.
public float ran1 = 6f;
public float ran2 = 6f;
Why is it properly updating its own UI element with the ‘5 and 1’, on its own screen, but then sending the default 6 and 6 values to the shared text element above it? And only on the client, as it does not happen on the Server+Client window.
In the Scene Script, triggered by a UI button:
public void Ran_Button()
{
playerScript.ran1 = Random.Range(1, 20);
playerScript.ran2 = Random.Range(1, 20);
//update the UI with the new values
Value1Text.text = “” + playerScript.ran1;
Value2Text.text = “” + playerScript.ran2;
playerScript.RanButtonUpdate();
}
In the player script:
public float ran1 = 6f;
public float ran2 = 6f;
[Command] //[ClientRpc] using this seems to have no change
public void RanButtonUpdate()
{
sceneScript.statusText = $“{playerName} {ran1} {ran2}”;
}
Each UI is updated with the new random values, per the button click, but the shared text is not being updated properly - it just shows the default 6/6’s from “public float ran1 = 6f;”
Any thoughts?
Thanks all