I am making a room timer for photon, the timer working fine for the master but shows null reference for client.
the second else statement in start function shows null reference on client
bool startTimer = false;
double timerIncrementValue;
double startTime;
[SerializeField] double timer = 20;
ExitGames.Client.Photon.Hashtable CustomeValue;
void Start()
{
if (PhotonNetwork.player.IsMasterClient)
{
CustomeValue = new ExitGames.Client.Photon.Hashtable();
startTime = PhotonNetwork.Time;
startTimer = true;
CustomeValue.Add("StartTime", startTime);
PhotonNetwork.CurrentRoom.SetCustomProperties(CustomeValue);
}
else
{
startTime = double.Parse(PhotonNetwork.CurrentRoom.CustomProperties["StartTime"].ToString());
startTimer = true;
}
}
void Update()
{
if (!startTimer) return;
timerIncrementValue = PhotonNetwork.Time - startTime;
if (timerIncrementValue >= timer)
{
//Timer Completed
//
}
}