Multiplayer Logic for RTS. Should i go this way?

So i have been trying to implement multiplayer into the RTS game of mine. I have found there are several ways of doing so, but i ended up deciding doing it via only sending player input to the server and sending the command back to all players for it to be played the next step.

For example: P1 sends a move command to the server, server verifies that such command is possible and sends an order for all players for this command to be played at the next second step (Making sure that if we receive command in the middle of the steps the order will have time to be delivered to all players). Then, players will send back a message saying that have successfully fulfilled the order at the specified step, if any player fails to do so it will require hard adjustments from the server (For example Vector3 position of the unit).

So my question is - Is this the way to go and if Netcode for Gameobjects has any tools to help to achieve this?

This seems like a logical approach.
I am assuming you are using NavAgents that will be traversing a Navmesh?
If so, then if you haven’t looked through the Navigation Samples I would highly recommend it as it will help you with determining valid paths. It also simplifies the commands (for motion at least) because players (if your RTS is this style) will be clicking on a destination location and the server will be determining if the unit(s) can reach that destination.

With that said… having players sending commands that the server validates sounds like a good start indeed!

Yes, i use unity`s own navmesh to navigate the world. From what i have read it is not deterministic meaning the position of the units will vary from client to client which will create additional problems to solve.

When i was referring to the tools i meant if anything that would help me determine if messages were sent to the clients and received successfully or should i store the commands manually and manually track their success from clients?

Ahh… yes we have all sorts of tools that you can customize to see what all is happening.

The majority of all messages are sent using reliable sequenced network delivery, which means when you send a message it should be delivered (to the destination clients and/or server) in the time relative order it was sent. Now, if you are interested in knowing whether a specific client has received a particular message there are a few options:

The Network Profiler allows you to create customized profile stats for your message types to “profile your message send/receive rates”.

The Runtime Network Stats Monitor allows you to create customized real-time/runtime graphs and counters for specific message types (or really any form of metrics you come up with based on messages sent or received).

The Network Scene Visualization is relatively new (only in the 2.0.0 pre-release), but it is worth taking it for a spin to see how we are evolving the netcode based tools to provide you with in-scene visual feedback for both troubleshooting and optimizing your product.

Of course, you can take this small helper class (attached NetworkManagerHelper) I use quite often (and modify based on what I am doing) when I just want to rapidly prototype something and want to be able to quickly iterate without having to put together a UI for starting a host or client (you can add an additional button to start as a server pretty easily) and be able to log output to the render view in a runtime (i.e. NetworkManagerHelper.Instance.LogMessage that also allows you to set the duration a message stays visible).

Additionally, there is the Multiplayer Play Mode tool that allows you to quickly create multiple sessions (virtual players) without having to create a stand alone build. Which you can always just log output to the console.

Finally, you can use the NGO NetworkLog class to have clients log messages that are sent to the local console output and if you use the server version of the log method the client will log information to the local console and send that same message to the host-server that will log that information to its console. The nice thing about NetworkLog (server based) messages is when it logs messages on the server-host side it includes the client identifier that sent the message.

As an example:
NetworkLog.LogInfoServer will log a normal message locally and then a normal message on the server-host of the current session. You can invoke server extended logging methods on a server or host as well, but it doesn’t send any messages…since it is being invoked on the server or host.

Let me know if any of these options are what you were looking for?

9516925–1341793–NetworkManagerHelper.zip (1.2 KB)

The tools you provided are useful when developing the game. But i was referring to the API methods that would be helpful in achieving what i am trying to do.
I am still collecting the information, so i will ask or make a thread when new questions arise.

Im also looking at NGO but I havent found the info I wanted in the docs.
The original post seems to be the right direction, however this is what I don’t understand:
If i have a KINEMATIC rigidbody lets say

  • I move its position via a command
  • I send that command through the network
    Can i trust that the results will be “deterministic” across machines (no cross play, PC only)? Or must I also sync the transforms of the rigidbody, when the command was issued, so to not accumulate errors over time?
    Because if not, then that would also explain why the navmeshagent is not determinisitc. Basically the whole engine can’t be trusted for transforms? Or since the its using the IEEE754 standard its going to be resonably similar?

Depending upon which kind of authoritative motion model you are using really depends upon where physics will be simulated.
If you are 100% client-server where the server is always updating the NetworkTransforms (i.e. no owner/client authoritative motion models), then the simulation is running on the server and clients are just mirroring the motion of the Rigidbodies.

If you are using a mix between server and owner authoritative motion models, then you could need to handle some of the physics related stuff between the non-kinematic and kinematic bodies.