using System.Collections;
using System.Collections.Generic;
using System.Threading.Tasks;
using Unity.Netcode;
using UnityEngine;

public class NetworkCharacter : NetworkBehaviour
{
    private NetworkVariable<ulong> palyerId = new NetworkVariable<ulong>(default, default, NetworkVariableWritePermission.Owner);

    public void SetPlayerId(ulong playerId)
    {
        if (IsServer == false) {
            return;
        }
        this.palyerId.Value = playerId;
    }

    public override void OnNetworkSpawn()
    {
        palyerId.OnValueChanged += OnPalyerIdChangedDelegate;
        SetPlayerIDDelayed();

        base.OnNetworkSpawn();
    }

    public void OnPalyerIdChangedDelegate(ulong previousValue, ulong newValue)
    {
    }

    async void SetPlayerIDDelayed()
    {
        await Task.Delay(100);
    }
}
