Overhead Names

Just a note. You can move the subscription of the name change to the Awake method, but on the client side, you still need to manually run the name change handler in order for the client to see the names. This must be because the host sets up the subscription BEFORE the names are changed. But the client sets up the subscription AFTER the name changes.

Basically the course has:

    private void Start()
    {
        HandleUserNameChange(string.Empty, tankPlayer.playerName.Value); //in case the name was already set
        tankPlayer.playerName.OnValueChanged += HandleUserNameChange;
    }

And this also works:

    private void Awake()
    {
        tankPlayer.playerName.OnValueChanged += HandleUserNameChange;
    }

    private void Start()
    {
        HandleUserNameChange(string.Empty, tankPlayer.playerName.Value); //in case the name was already set
    }

Thanks!

Julian

Privacy & Terms