I’m working on a networked game. We have it running and as long as nobody disconnects the game is playable. Now we’re working on players dropping and reconnecting. So I’m recovering the visual state of replicated objects from BeginPlay(), but only the ones that have PlayerController as owner. The objects spawned by the world (and thus not the Player or PlayerController) do NOT get server values in BeginPlay() because their PostNetInit() doesn’t get called. The goal here is to override local values on the client with server values but only a single time when connection is established, actor replication kicks in, and (most importantly) the values on the server have already been replicated to client.
Is there a function or delegate:
- for objects NOT owned by PlayerController
- that gets called before or after BeginPlay()
- that gets called once per game connecting to server (like BeginPlay() or PostInitializeComponents()
- that has the server data already replicated to the client
I have tried these:
virtual void OnActorChannelOpen(class FInBunch& InBunch, class UNetConnection Connection) {};
- this one didn’t seem to have server data, only client data was there
virtual void PostNetReceive() override;
- this one happens every time replicated data is synced, not just once
virtual void PostNetInit();
- this one doesn’t happen on actors not owned by PlayerController
virtual void OnReplicationPausedChanged(bool bIsReplicationPaused);
- this one didn’t fire for me on objects not owned by PlayerController