fgm24/Assets/Scripts/Utilities/NetworkID.cs

19 lines
340 B
C#
Raw Normal View History

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;
}
}