#First Time Trying Multiplayer; Best Practice and pitfalls to avoid

1 messages · Page 1 of 1 (latest)

fair owl
#

As the title states, I am trying to develop a multiplayer game for the very first time! :)
I've been developing solo projects for the last 2 years, and have wanted to try make silly multiplayer things to try get to know how Multiplayer works.
I've been working on this new project for 1 week, and at the moment I've only got it to connect 2 clients using Relay.
I am using NGO but I am really really struggling to understand how and when to use ServerRPCs, or ClientRPCs, how to reference, and just generally how to actually code anything that replicates properly

I don't expect a holy grail of information to perfectly solve all my headache, but I would really appreciate any and all advice about working with Multiplayer! :)
And considering this is a new Thread section, maybe its worth having a pinned thread that has some easy to digest information for people starting out to try help them wrap their heads around Networking

Sorry for the Long text, but thank you in advance for any and all responses Pray_For_That

winter raptor
#

Howdy, My plan was to use the General Thread for General advice. But you want to work towards making your game more data oriented. Focus on sending as little data as possible across the network. There are many many ways of going everything and there are exceptions to every rule.

fair owl
# winter raptor Howdy, My plan was to use the General Thread for General advice. But you want to...

I see that but I also feel depending on how often general chatter is in there, it might make advice difficult to find amongst the people chatting
But that's just a possible suggestion
And when you say Make my game more data oriented, how so do you mean?
Are you saying more-so when designing systems, put the majority of the emphasis on the design on what it needs to communicate, and how to do it within the confines of Network transfers?

winter raptor
#

Yea. objects(any nullable types) can't be sent over the network. Data Oriented Design is super helpful in this regard. It keeps your code cleaner and you get a nice reduction in garbage collection when done right.

tepid pewter
# fair owl As the title states, I am trying to develop a multiplayer game for the very firs...

It's quite a substantial change of pace. Luckily there are a good amount of tutorials and the documentation is packed with examples. Following a tutorial series and filling in any gaps with the documentation is what I'd recommend.

If you're struggling with RPCs and the general idea of replication there's a couple of ideas that are important to keep in mind that I think a lot of beginners just gloss over:

  • If you and I are playing a local co-op game on the same machine, then there's your player object and my player object. When dealing with a multiplayer game it's important to remember that that scenario all of the sudden becomes 4 player objects. On my application I have copies of our player objects, and on your application you have copies of them as well. Beginners often get stuck in the habit of "I changed this on my object" and expect changes to replicate automatically. Syncing has to reach all instances of an object.
  • RPCs are basically just fancy wrappers that say "Run this function on the target". ServerRpc being for a client to request the server to run a function, and vice versa for ClientRpc. They're useful for quick, one-off actions; like communicating a button press, requesting an object to be spawned, sending a chat message, etc.