I need some help with this server/client interaction please!


I have player data that I want to pass to the server when the player joins a session. I was initially using OnPostLogin in GameMode, but there were issues with latency and I didn’t want to rely on a random delay, so figured I’d instead go with:

Client posses pawn-> Client gets their data from their GameInstance (which pulls said data at login screen from save file) → Client sends data to server → server adds data to list → server tells host to update their hud with player name (with short delay to ensure HUD is up).

The problem is that the data is always just the host data. I have tried both with/without replicating the data variable itself.

If someone could please point me in a good direction, I’d be most grateful.

The idea is good, but don’t use event On Possess. That event only runs on server-side, so you cannot retrieve the client’s data there.

You can use event BeginPlay from PlayerController, that triggers on both server and client.

Filter for client by checking “Is Local Controller” or “Is Local Player Controller”, then get game instance and send data to server.

Oh heck, I didn’t even know it only ran on server. That explains a lot, lol. I had initially thought of running OnBeginPlay but I was worried about not having enough time for the HUD and data to populate. I’ve been trying to avoid delays, but it’s rough to figure out.

I will give that a shot, thank you. I’ll let you know if it works.

Hey, I can get the information now (YAY!) by calling at the end of Begin Play, but on the server, my HUD update isn’t showing up. I’m running via LAN, 2 player Standalone, and the HUD definitely exists. It DOES populate with the server name, but it says the HUD invalid when the function is called by the client. Also the controller seems to be the client on both ends.


problem2

Ah I figured it out.

If anyone has this issue in the future, this is what I did:


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