Hello im having problem with a scoreboard, when i try to synchronize an int which in this case is number of deaths, they dont really synchronize at all over the network. Here’s my scoreboard script. I’d love to know what the problem is!
Thanks
using UnityEngine;
using UnityEngine.UI;
using System.Collections;
public class Scoreboard : MonoBehaviour
{
public GameObject ScoreboardGO;
//Team stuff
public int Team1K;
public int Team2K;
//Text
public Text Team1Text;
public Text Team2Text;
//synchronization part!!
//HERE IS THE PROBLEM
void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info)
{
if (stream.isWriting)
{
stream.SendNext(Team1K);
}
else
{
Team1K = (int)stream.ReceiveNext();
}
}
void Update()
{
//THIS IS JUST FOR DEBUGGING
if(Input.GetKeyDown(KeyCode.C))
{
Team1K += 1;
}
//Setting scoreboard and toggeling
if(Input.GetKey(KeyCode.Tab))
{
ScoreboardGO.SetActive(true);
}
else
{
ScoreboardGO.SetActive(false);
}
//Set int to text
Team1Text.text = Team1K.ToString("F0");
Team2Text.text = Team2K.ToString("F0");
}
}