#Problem with multiplayer:
40 messages · Page 1 of 1 (latest)
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?
Alright. Then what is the purpose of rpc_id if the remote node’s peer_id is supposed to be the same?
yeah pretty much
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...
yeah since the hp of the player gets synced anyway it doesn't really matter, however using rpc would be a bit less optimal, since you effectively send the information twice.
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.
Yes, you are right, I didn’t fully understand the tutorial from the video.
Also, do you know what might be causing this issue (in my project)? I copied the code from a tutorial, so the issue is clearly not with the code. But when I try to connect a third node to the game, Godot freezes, and then a graphics driver error pops up, forcing me to close Godot through the Task Manager. This doesn’t happen with the project from the tutorial.
what exactly do you mean with connecting a third node?
oh my bad, this is probably machine translated
yes(( sorry
do you mean a third peer?
yes
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?
The script is the same as in the tutorial I mentioned, with maybe some of my clumsy adjustments, but I don’t think there’s anything critical there. If needed, I can show the main script.
The video recording was interrupted due to an error and the entire computer freezing.
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?
There don't seem to be any serious errors, but my graphics card makes a lot of noise when connecting players, and recently the AMD panel has been glitching and doesn't always open or record video. This didn't happen before, and the same project worked fine even with three players. I'll try reinstalling the drivers.
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.
so the errors only exist in the case of a third player?
yes
On the other hand, it doesn’t seem like a GPU overload because three open windows work fine as long as the third player isn’t connected.
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.
Unfortunately, I’m a beginner and don’t know how to perform this check.
just do if enet_peer.create_server() == OK
The client and server show OK, but there’s one issue: the crash happens even without three connected players. If the host is created, the client connects, then disconnects, and reconnects again, the game still crashes.
hm, how does your player script look like?
Hmm, I tried spawning something other than a player, like any other scene, and the crash doesn’t happen. The issue really seems to be with CharacterBody3D.
Here’s the script, but most of it is right here.