hello! i want to make a countdown timer when all players join a room. Problem is the code doesnt print timer on players screen, any ideas?
if (Network.isServer) {
players += count;
if (players == allplayers) {
networkView.RPC ("countTime", RPCMode.Server,Time.time);
}
}
[RPC]void countTime(float startTime)
{
if (Network.isServer) {
remainingTime = Time.time - startTime;
restSeconds = countDownSeconds - (remainingTime);
if (restSeconds < 0) {
restSeconds = 0.0f;
}
//display the timer
roundedRestSeconds = Mathf.CeilToInt (restSeconds);
displaySeconds = roundedRestSeconds % 60;
displayMinutes = (roundedRestSeconds / 60) % 60;
text = string.Format ("{0:00}:{1:00}", displayMinutes, displaySeconds);
networkView.RPC ("setTimer", RPCMode.All, text);
if (displaySeconds == 0 && displayMinutes == 0) {
networkView.RPC ("TimesUP", RPCMode.All, true);
}
}
}
[RPC]void setTimer(string text)
{
this.text=text;
}
which i print with GUI.Label OnGUI() function