Hello! I've been struggling with Unity Mirror's networking functions, specifically with the execution of commands. While the game runs smoothly in the Unity Editor, I'm facing difficulties when running the Mirror build. Despite the initial debug message appearing, the CmdDealCards command is never called, and subsequent parts of the code aren't triggered. I've checked the network setup, authority, and even added extensive logging, but the issue persists. Any insights or suggestions would be greatly appreciated!
I haven't gotten Mirror to work in about 4 months. And honestly at this point, I can't even remember if I ever had an instance of it working. To be a little more specific though, this is a 2D card game and I have the following code on a button:
public void OnClick()
{
Debug.Log("You clicked the button.");
NetworkIdentity networkId = NetworkClient.connection.identity;
PlayerManager = networkId.GetComponent<PlayerManagerScript>();
Debug.Log(networkId.isOwned);
PlayerManager.CmdDealCards(DrawAmount);
DrawAmount = 1;
UpdateTextbox();
}
All of that executes just fine... but the CmdDealCards seems to never work. On the PlayerManager I have the following code:
[Command]
public void CmdDealCards(int DrawAmount)
{
Debug.Log("You tried to create the card(s).");
for (int cardNumberDrawn = 0; cardNumberDrawn < DrawAmount; cardNumberDrawn++)
{
//The rest of this doesn't matter.
}
Debug.Log("This triggered.");
SortHand("Hand Area");
}
The "You tried" Log never executes. It all works perfectly fine in single player using the Unity Editor. But as soon as there's a Mirror Build involved, it breaks. It seems to be a problem outside of the code, but I can't seem to find the answer, even with hours of asking ChatGPT.
Just so you know, this is my first Unity Project. I'm a total noob.