Hi all, I’m having a lot of trouble with UNET, trying to understand how to implement a discrete client/server setup.
With the old system I could create my client, and my server, connect, and use RPCs to do everything I wanted. Now… I have no idea, and it’s kinda frustrating because I want to do some really basic things.
I’ve read through the documentation, watched a few hours worth of tutorials, and downloaded sample projects, as well as trawled through these questions to see if anyone has my problem, and no luck so far.
Specifically;
From the documentation, server works fine
public void SetupServer()
{
NetworkServer.Listen(4445);
isAtStartup = false;
}
Client connects
void ConnectToServer()
{
myClient = new NetworkClient();
myClient.RegisterHandler(MsgType.Connect, OnConnected);
myClient.Connect(“127.0.0.1”, 4445);
}
How do I execute the equivalent of an RPC? Say, from the client, I want to send a simple string to the server? I’ll then want to send that string to clients.
I’ve read about [Command] and [ClientRPC] and [ClientCallback], but literally every example I’ve found uses a game that can act as host, client, or both. In the project I’m working on there is no need to run the game as a host, because it’s not that type of multiplayer.
Consider it asynchronous. A client will play, and at some point some updates will be sent to the server (a score, for example). And all that server will do is store that information, and at some point propagate it out to clients.
Can anyone give direction on the best way to achieve this kind of system? Can I use [Command] [ClientRPC]? How do I implement them when they aren’t sharing the same application codebase and thus don’t have the same methods/functions? (do they need to? RPCs had to be on both client and server, but you could leave the one which didn’t need to execute anything blank - is it like this?)
Any help appreciated
Thanks