When clients connect to a server, an RpcId is called with an id of 1 and spawns a player to the scene.
The only visible players are the clients on the server's screen. Is there a simple way of making them all visible?
How do i make all players visible on screens?
TheEpicCookie Can you tell a little bit more about your case? What you've already made, or some code example?
- Edited
xolatgames `public override void _Ready()
{
Multiplayer.ConnectedToServer += OnConnectedToServer;
}
private void OnConnectedToServer()
{
GD.Print("Connected to server");
clientId = Multiplayer.GetUniqueId();
RpcId(1, "CreatePlayer", clientId);
}
[Rpc(MultiplayerApi.RpcMode.AnyPeer, CallLocal = true, TransferMode = MultiplayerPeer.TransferModeEnum.Reliable)]
private void CreatePlayer(long id)
{
var PlayerScene = playerScene.Instantiate<Node2D>();
var playerScr = PlayerScene as Player;
playerScr.playerId = (int)id;
AddChild(PlayerScene);
}`
TheEpicCookie make sure the rpc is called on all clients.
kuligs2 `private void OnConnectedToServer()
{
GD.Print("Connected to server");
clientId = Multiplayer.GetUniqueId();
Rpc("CreatePlayer", 1);
Rpc("CreatePlayer", clientId);
}`
Now the server sees the clients, but the clients can't see each other.
TheEpicCookie because you dont call the rpc on all clients. The server serves data to all clients but if client dont have the "scene" or other objects that server has then that client dont see "other clients".. You need to replicate the scene on all clients and server, by calling the same RPC funtion on all clients. And why are you using c#?
Look at this
https://docs.godotengine.org/en/4.3/tutorials/networking/high_level_multiplayer.html
Its in gdscript
kuligs2 I can't get it to work. Multiplayer is so hard, also what's wrong with using C#?
TheEpicCookie its not hard, you just need to read this and understand how it all works
https://docs.godotengine.org/en/4.3/tutorials/networking/high_level_multiplayer.html#example-lobby-implementation
there is a whole example.
Personal opinion: C# is bloated with unnecessary things imo like long syntaxes and its not compact to read through.. and you have to be type speciffic and is not agnostic in sense that its MS product while gdscript is OS agnostic while you use godot. And so when godot was is written it puts gdscript at the forefront while C# gets 2nd hand treatment..
kuligs2 Ah, alright thanks!