NetworkIdentityReference can be used for synclists
public class MyBehaviour : NetworkBehaviour
{
public SyncList<NetworkIdentityReference> others = new SyncList<NetworkIdentityReference>();
public override void OnStartClient()
{
foreach (NetworkIdentity other in others)
{
Debug.Log($"this {netId} other {other?.netId}");
}
}
}
spawn and add references
NetIdRef clone1 = Instantiate(prefabWithNetIdRef);
NetIdRef clone2 = Instantiate(prefabWithNetIdRef);
NetworkServer.Spawn(clone1.gameObject);
NetworkServer.Spawn(clone2.gameObject);
// reference each other
clone1.others.Add(clone2.netIdentity);
clone2.others.Add(clone1.netIdentity);