This is a little bit more of not a specific problem but just trying to get a greater understanding of RPCs. I’ve started to dabble in multiplayer taking a read through the documentation and tutorials online. What I can’t really get a handle on is what I actually use RPCs for?
I think I understand what they are holistically/the idea of them is used for, essentially allow the server to make calls on other peers but I can’t think why I would use this exactly.
I was hoping some people could provide some real game examples of when you would use an RPC?
Let’s say I have one peer launch a spell at another peer and I want something to happen when that spell hits the peer (such as getting knockedback or damaged). Would I use an RPC to initiate that or is that fine just being handled by a normal collision check and signals.
What about if I want to spawn a projectile, do I need to use an RPC to sync the client peer back to the server or is this particular problem handled by the MultiplayerSynchronizer and MultiplayerSpawner nodes.
Can it be boiled down to basically ‘if I need a peer to do something to another peer then it should be an RPC?’ or is that oversimplying or way too incorrect.
First, RPC isn’t the only way to do multiplayer, but it is the method Godot’s developers have chosen. My own multiplayer uses UDP and TCP directly, but the general principle is identical.
You send a packet to the server whenever you want to inform the server (or other players) of something happening in the game. It can be a change in position/direction of a player, a shot attempted, damage taken, an item picked up, etc. Exactly which packets are sent will depend on the nature of the network architecture you have chosen, and the nature of your game.
Thanks for that. This seems to imply that anything that the server and other players needs to know about, really should be an RPC.
Though it does seem like a little bit of this is handled by the MultiplayerSynchronizer nodes (such as position and rotation and whatever else you can put into that replication tab)
So in my example if I want a peer to know that they have been knockedback by someone then that function should be an RPC? Of course if I continue to use the Godot RPC method.
As an aside do you have any decent articles that you can reference about multiplayer outside of using Godot’s built in feature set? It might help me understand this more. (Looks like the Godot documentation makes references to some networking articles such as Gaffer On Games)