ClientRpc not functioning
This is a simple program designed to keep track of the number of players connected to the server, for debugging purposes, in the start method, I had just the server set its clientCount to -10 to see if by using [ClientRpc] the -10 could be sent to the clients, however, the client never received the -10 and end up staying at -1 (for these tests I was using a dedicated server and a separate application running the client, not a host that is both a server and a client). For context sake, here is a picture of the GameObject it is attached to (the selected one):
There seems to be a lot of outdated info out there and very little info on what I actually need to do so if someone can help, that would be great! :)
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Networking;
using UnityEngine.UI;
public class ClientManager : NetworkBehaviour {
private static int clientCount = -1;
//--------------------------------------------------
// Use this for initialization
void Start () {
if (isServer) {
clientCount = -10;
}
}
//--------------------------------------------------
// Update is called once per frame
void Update () {
if (isServer) {
RpcSendClientCount (clientCount);
}
}
//--------------------------------------------------
public static int ClientCount
{
get
{
return clientCount;
}
set
{
clientCount = value;
}
}
[ClientRpc]
void RpcSendClientCount (int count)
{
clientCount = count;
}
}
Your answer
Follow this Question
Related Questions
[uNet] Multiple Spawnpoints with Selection 0 Answers
uNet. Spawning objects over the network. 0 Answers
Rayscast from the GameObject that is not the player does not work 0 Answers
item not adding to list correctly! 1 Answer
UNET: Network.isServer/isClient = False; PeerType = Disconnected but accepting connections? 0 Answers