Adapting the Strategy Course for Multiplayer

Hello, loved the strategy course and thought it was amazingly thorough. Really expanded my game knowledge. Moving forward, I’ve tried to look into making the game multiplayer, but have really had trouble adapting existing multiplayer courses into the framework that has already been set up. I’ve been using Unity Netcode for Game Objects.

I figured that having the Unit class inherit from NetworkBehaviour is important, but I don’t really understand how I would assign a group of Units to a singular player. Nor do I really understand how I would allow that player to move only those Units. I’ve seen other people saying they’ve had success with adapting this to multiplayer, so I was really hoping I’d be able to find some pointers as to where to look or anything that would be helpful.

Thank you and thanks again for the great course. Well worth the cost

There are already Units which can’t be selected by the player, simply by setting the isEnemy bool to true. So my first thought would be to have a variable to track which Units belong to which player, for example you could have an int player and Player 1 will be able to select Units who have that variable set to 1.

That makes sense. And then I guess I could make TakeAction be a ServerRpc to allow clients to actually perform actions? Thanks for the tips

1 Like

I’ve added a unity-multiplayer tag to this to get voices from that course involved. I can tell you that this is the sort of thing that needs to be done from the ground up. My personal advice would be to start the project from the beginning, employing the principles used in Nathan’s Netcode course right away.

I can definitely agree with that sentiment, going back and implementing everything is a pain. Really understanding exactly what you want to be doing with the network seems to be essential. That being said, I’ve managed to get most stuff -functional- but nothing too impressive. Definitely was interesting to have a functional game and then working backwards and seeing what exactly I can send easily.

I will definitely check out that other course though, to really solidify my understanding of these concepts. Thanks for the suggestion, really appreciate it

Hi there, TA from the multiplayer course here.
As Brian said, it is much easier to build in the multiplayer functionality from the beginning.

The focus of the multiplayer course is really assigning ownership and authority to objects and separating client and server logic. Along with this is how to pass data across the network.

You will need to inherit from NetowrkBehaviour instead of MonoBehaviour in any place where you need to send data over the network. This could be a NetowrkVariable, NetworkList or a remote command (RPC).

In terms of giving specific players control of specific units, this is where authority and server/client logic comes in. Most like for a turn based game, you will want everything to be server authoritative. This means the server will have the final say over any actions, and can sync its updates to the clients.

Clients can request changes, like moving a unit, by sending remote commands to the server. You can assign ownership to units so you know which client the units belong to. That way the server can check the client commands against the ownership to see if the requested action is allowed.

Again this is much easier to do from the beginning, because separating out what needs to be a remote command and what needs to be server logic and what data needs to be synced over the network is very difficult to integrate in retrospect.

That is kind of the basic way to look at it. I suggest focusing on sending data over the network, remote commands, authority and ownership to start. Unity has lots of good documentation on this stuff. I am happy answer more questions, but the best way is of course to take the UGS course. Good luck!

Privacy & Terms