public void NetworkInstantiate(string prefabName, Vector3 position, Quaternion rotation) { int newObjectId = 0; int subId = _LastUsedSubId; int localActorId = _MultiplayerClient.LocalActorId; int ownerIdOffset = NetworkDataSize.MaxNetworkObjectID * localActorId; for (int i = 1; i <= NetworkDataSize.MaxNetworkObjectID; i++) { subId = (subId + 1) % NetworkDataSize.MaxNetworkObjectID; if (subId == 0) { continue; // avoid using subID 0 } newObjectId = subId + ownerIdOffset; if (!_LocalObjectDictionary.ContainsKey(newObjectId)) { _LastUsedSubId = newObjectId; break; } } GameObject prefab = Resources.Load <GameObject>(prefabName); _LocalObjectDictionary[newObjectId] = Instantiate(prefab, position, rotation); _LocalObjectDictionary[newObjectId].name = newObjectId.ToString(); NetDataWriter dataWriter = new NetDataWriter(); dataWriter.Put(NetworkDataType.NetworkInstantiate); dataWriter.Put(newObjectId); dataWriter.Put(prefabName); dataWriter.Put(position.x); dataWriter.Put(position.y); dataWriter.Put(position.z); dataWriter.Put(rotation.x); dataWriter.Put(rotation.y); dataWriter.Put(rotation.z); dataWriter.Put(rotation.w); Debug.Log("NetworkInstantiate @GameClient"); _MultiplayerClient.SendData(dataWriter); Debug.Log("Sent InstantiateData @GameClient"); }