#Problem with multiplayer:

40 messages · Page 1 of 1 (latest)

silver herald
#

Translation to English:

Problem with multiplayer:
When I call a function using @rpc, it is only triggered for one node (player), but it should ideally be triggered for all nodes. I’ve been unable to solve this problem for a long time; maybe I’m misunderstanding something.

pliant canyon
# silver herald **Translation to English:** Problem with multiplayer: When I call a function ...

rpcs (remode procedure call) are used to call functions on the same node of a different instance of the game, either on the same machine or over a network. what you describe doesn't sound like it has anything to do with networking/multiplayer.
that's why you define it for each node individually. and think about it, not every node is guaranteed to have a method with the same name and the same arguments, so how is what you describe supposed to work in practice?

silver herald
silver herald
#

https://www.youtube.com/watch?v=n8D3vEx7NAE
In this video, from 35:39 to 36:15, rpc_id is used, but if you just use rpc, the result will be the same.

How to make a simple online multiplayer FPS game in Godot 4 and play with friends over the internet. Big thank you to @ditzyninja for his Godot 4 networking content!
Git Repo: https://github.com/devloglogan/MultiplayerFPSTutorial

0:00 Intro

=== Blender Modeling ===
0:34 Environment Model
3:48 Pistol Model

=== Godot 4 Project Setup ===
6:56 Im...

▶ Play video
pliant canyon
#

and there could be cases where it really is important to call an rpc only on one peer.

#

although it'S usually better to make sure it also work with just rpc, since a player could modify their game so it sends rpcs to peers it wasn't supposed to, so checking on the recieving end is probably still a good idea.

silver herald
silver herald
pliant canyon
#

oh my bad, this is probably machine translated

silver herald
pliant canyon
#

do you mean a third peer?

silver herald
pliant canyon
#

hm, i never had a graphics driver error, and i also don't understand how this could be caused by adding another peer.

#

can you show the script you use to connect the peers?

silver herald
silver herald
pliant canyon
#

okay this is really weird, you limited the max player count to 5, but that shouldn't cause problems with 3 players.

#

i noticed quite a few errors that you have in the editor before starting the project, could you show those?

silver herald
silver herald
#

This happened when I tried to launch the third player, just by creating the host. I'm not sure anymore if the problem is with the project itself; maybe I should try running it on a different device.

pliant canyon
#

so the errors only exist in the case of a third player?

silver herald
pliant canyon
#

what you can do is check the error code the create_server() and create_client() methods return, and only continue if that code equals OK.

#

it's also strange that you get the error on creating a host, which should only have been the first one.

silver herald
pliant canyon
silver herald
pliant canyon
silver herald
#

Here’s the script, but most of it is right here.

pliant canyon
#

you probably didn't have to zip that file. scripts are pretty small.

#

and the playerscript doesn't seem to have anything suspicious, it probably has to be something that communicates with the other peers.