19 lines
340 B
C#
19 lines
340 B
C#
|
using UnityEngine;
|
||
|
using Unity.Netcode;
|
||
|
|
||
|
public class NetworkID : NetworkBehaviour
|
||
|
{
|
||
|
// Set from enemy spawner
|
||
|
public int InitialID = -1;
|
||
|
|
||
|
private NetworkVariable<int> nID = new();
|
||
|
|
||
|
public int ID => nID.Value;
|
||
|
|
||
|
public override void OnNetworkSpawn()
|
||
|
{
|
||
|
if (IsServer)
|
||
|
nID.Value = InitialID;
|
||
|
}
|
||
|
}
|