Unity Forge Networking: client's score doesn't get saved

614 views Asked by At

I am having an issue with forge networking.I have finished beginner tutorials and now I wanted to create my own project.It is very simple:I create a local game on one of my devices and client connects.Each of them(client and host) enter their number, and then host's number is displayed to client and vice versa.However, client's number never gets saved and host always sees 0 for client's number, while the actual number is different(the host's number is getting saved and synchronized through the network properly and client CAN read it). I took these steps in creating this project: 1) in forge network contract wizard I have created 2 variables for storing numbers 2) i created a simple script for saving and loading those 2 numbers(this script is attached to an empty game object) :

 public void UpdateNumber(Text Nmbr)//Button!
 {
     if (!networkObject.IsServer) {
         networkObject.clientNmbr = int.Parse (Nmbr.text);
     } else {
         networkObject.hostNmbr = int.Parse (Nmbr.text);
     }
 }

 public void ShowText(Text text)
 {
     if (networkObject.IsServer ) {

         text.text = "client:" + networkObject.clientNmbr;
     } else {

         text.text = "host:" + networkObject.hostNmbr;
     }

 }

I don't see why this works for host but doesn't work for the client

0

There are 0 answers