I am working on a project where there are 2 players, 1 is a host/client, and the other is a client and I want both of the players to be able to have access to and the ability to update the variables of a game object’s script and have that change be updated on both the server and the client, regardless of who changes it.
Scenario 1
Player1(Server/client) changes int numOfUnits from 10 to 9.
Player1(Server/client) now sees int numOfUnits as 9.
Player2(Client) now see’s int numOfUnits as 9.
Scenario 2
Player2(Client) changes int numOfUnits from 9 to 8;
Player 2(Client) now sees int numOfUnits as 8.
Player1(Server/Client) now sees int numOfUnits as 8.
If I’m reading the unity documentation correctly, SyncVars functionality doesn’t seem to be the right approach, because variables are only updated and broadcast to clients if the server itself makes changes to the game object script’s variables and then broadcasts the change to clients, but not the other way around (correct me if I’m wrong there).
What methodology would you suggest as a solution to allow a sort of 2 way street, where 1 game object can be modified by both the server and the client and both the server and the client see’s the changes?
I’m very new to unity networking. Sorry if this is a question that’s been asked before.