Localplayer representation on remote clients only

Hey everyone,

I have the requirement of showing a few assets for every other player in a networked environment, like an Avatar or player number on their head. I want to avoid to spawn anything for the local player, he doesn’t need to see anything from these about himself.
The spawn also needs to consider some attributes from the actual player, like menu configuration and such.
I can’t use OnStartClient, because it’s called on all of the instances and isLocalPlayer is not set at that point. There’s no OnNonLocalPlayerStart, so the furthest I could get was to use OnLocalPlayerStart and then execute a commmand rpc chain from there for all the others to receive the relevant data while ignoring that in the local player.
BUT what about players that join later, they won’t receive the rpc? So I used syncvars for them to get their actual state. But where do I read it or? In Start? In OnStartClient? I’m stuck here because there’s no combination that doesn’t involve running the spawn stuff twice for players that check their start and receive the rpc… How do I do this right?

Every nonlocalplayer should spawn stuff with information abhor the localplayer, but only once, meaning after OnLocalPlayerStart ran for the actual local player. I can’t think of a solution.

Here is my own solution:

  • The client has SyncVar fields for what’s important for the nonPlayers and one bool like ready, or setup
  • In OnClientConnect, the bool is checked and skipped if it has not been set yet
  • In OnLocalPlayerStart() a Command is called to inform the server about all values and the bool is set ready
  • Clients receive that Command and can react to it

The boolean is mandatory for new players, since they wont receive the command and wont get any hooks called because they just start with everything setup, so they need to know if the info about their localplayer instance is known by now.