Multiplayer all Clients are Client 0?

Using print string in for example character bp, when running 2 clients with server in background. Netmode is client that is. Strings showing on the screen are prefixed with server and client #number. But i am getting only server and all other clients are client 0?? i can have 3 clients, and i will get the print string once from server and all other are from client 0?
What am i missing? before it would write out client 0, 1, 2…depending om how many.

1 Like

In game mode class when the controllers are assigned you need to set a value in the player state. Then read that value per client for the print.

Yeah but as far as i know there is no accessible variable in playerstate that controls the “Client 0” which i would expect to increase for every client connected. Sure i can use the playerid, but still annoying to see the debug on screen always showing Client 0 PlayerId 2 or whatever i print… its always client 0.

Thank you for the tip anyway, will try using playerid to make sense of which client is which.

Realistically you should be creating your own custom player state class. This is where you should be storing Health, Max Health, Player Name, Score, Is Alive?, etc etc etc.

Yes that is true. But this was more from debugging perspective, to easily see what client was executing what and where. I was having a problem where client 1 was executing a delegate but client 2 was not. This was strange as the same delegate is bound in the same place in code. Both clients should be executing it. But only one client was executing the delegate and the dedicated server. Client 2, was not firing it off at all. My frustration was that all print strings were showing client 0… so i had no idea what was going on. I did at last find out that GAS behaves very strange sometimes when running server in the background in same instance… so i solved that. But the client 0 thing is still very strange to me.
Thank you for your replys never the less.

it depends where it called i think, the client will return 0 but the server will return the correct value

i notice i was having the same issue so i tested fresh untouched projects. when i opened a fresh 5.2 project the print string works as expected. shows server: hello client 0: hello client 1: hello but when trying in 5.3 it fires sever: hello client 0: hello client 0: hello. i believe something in the unreal code itself changed but i am very very new to unreal sooo take it as is lol

4 Likes

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.