Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | ana_rchy |
im trying to get usernames working for my multiplayer games (in the sense of a hovering label above each player) for about… a full day worth of trial and error(?) now and still no luck, i usually end up with a result where every player node has the same name as what the client has
i came up with a solution which i thought for sure would work, that being sending an rset
on ready if the node is the network master, and if not, call an rpc for a function that makes the master node call rset
using Godot; using System; public class Username : Label { /* setup */ private Client UserClient; ``` public override void _Ready() { RsetConfig("text", MultiplayerAPI.RPCMode.Puppet); UserClient = GetNode("/root/Server"); Text = UserClient.Username; if (IsNetworkMaster()) { Rset("text", UserClient.Username); GD.Print("is network master"); } else { Rpc(nameof(_RsetForNewPlayer)); GD.Print("is not network master"); } } ///////////////////////////////////////////////////////////////////////////////////// /* rpc */ [Remote] public void _RsetForNewPlayer() { if (IsNetworkMaster()) { Rset("text", UserClient.Username); GD.Print("received"); } } ``` }
but of course, it just had to not work. i noticed that both “is network master” and “is not network master” print fine, but “received” is never printed
so the only conclusion i can make of this is that rpc is broken in some way, or i somehow fucked it up, im not sure. all i know is its never received and thats been causing me a migraine for the past few days. any ideas why or how to fix it?