Hey, I’m working on a mobile real time multiplayer game using UNET, and wanted to ask some general questions - they aren’t really related to each other:
Is UNET production ready? Does any released game use it in large scale?
Is UNET’s WebSockets production ready? Does it add any overhead / fit to be used as a solution for high paced network communication?
Assuming I want to make sure that my client and server simulations are the same, I decided to implement all logic on the client using FixedUpdate (to ensure having the same delta times) - is this a good approach? If not, what would be a better one?
Currently (in my POC) I send an “input command” for every FixedUpdate frame - this works OK, but I’m sure it won’t scale very well - what is considered best practice to send out player input to the server?
Is there a way to send data to a specific person using the normal serialization flow (OnSerialize/SyncVars)? For example, I want to send the position and rotation of a player to everyone, but his ammo should only be sent to him (and I would prefer to stay in the HLAPI and not start managing connections and using something like NetworkServer.SendToClient)
Is it possible to control the send interval per connection? For example, I want to send lots of updates to the owning player, but less for other players (as it’s less important and just uses up bandwidth)
Youshould retrieve the client input in Update frames, no FixedUpdates. But I guess you are sending all the input the server… Most Unity multiplayer games use Client authoritative players (for movement for example), but the game (stats, skills, etc) is handled on server, but I get why you want to do it this way !
You can send [COMMANDS] or use the TransportLayer API.
Well ClientRPC calls are here ! and there is the isLocalPlayer (NetworkBehaviour) variable to check if this is the player script of the current client.
If you use NetworkTransform, you can change the ratio, but if you talk of scripting, it depends on what you send ! Still look at the NetworkManager Documentation
I don’t think any companies use it for large scale games or anything. I’ve worked with UNET since release pretty much, and I’d say it’s ready. The development flow is very good compared to 3rd party plugins. There’s also the relay server if you have the money to spend, with the option to not use it too. In my opinion it is ready.
I haven’t really had the need to use WebSockets, but I can only imagine that they’re working pretty good. I’ve used a bit of native WebSockets, and they worked just fine for me.
Your approach seems fine. I’m assuming you want client prediction and such, and in this case you just have to have the same logic. Which means having the same logic in the same updates and so on.
Sending a message every FixedUpdate is very taxing. The default rate is at 50 times a second. This is a lot for networking. You usually want something more like 10 times a second or so, and then just interpolate between the states. The NetworkTransform allows you to all the way up to 29 times a second, which in my opinion is also the absolute maximum, unless you want to spend all the users/servers bandwidth. You can look at the source code for the NetworkTransform, it shows how you can limit how often data is sent. It’s right here, along with most of UNETs HLAPI…
As far as I know, there is not. You have to use the message system or NetworkWriter/Reader to send to specific connections.
I haven’t actually tried this, but everything tells me that it’s possible. If you look at the NetworkTransform, you can see how they have implemented sending rates. The receiving end doesn’t actually care about the rate, so you can just change the rate of which you send, which is quite easy to set through a variable. You might have to do this per object, instead of per connection though. But it’s easy to get the players object, so it shouldn’t be a problem.
I really took a lot of inspiration from the NetworkTransform code and implemented my own “interval network sender”, which can be used for anything from sending input to state.
So now I can combine the input and send it every interval of my choosing (10 times / second seems like a good ratio).
And yes, I am implementing an authoritative server and using player prediction on the clients.