Worker 네트워크 동기화
This commit is contained in:
@@ -94,7 +94,7 @@ namespace Northbound
|
||||
|
||||
GameObject workerObj = Instantiate(workerPrefab, spawnPosition, Quaternion.identity);
|
||||
NetworkObject workerNetObj = workerObj.GetComponent<NetworkObject>();
|
||||
|
||||
|
||||
if (workerNetObj == null)
|
||||
{
|
||||
Debug.LogError("[WorkerSpawner] Worker prefab must have NetworkObject component");
|
||||
@@ -102,18 +102,19 @@ namespace Northbound
|
||||
return;
|
||||
}
|
||||
|
||||
workerNetObj.Spawn();
|
||||
_lastSpawnTime = Time.time;
|
||||
_workerCount.Value++;
|
||||
// IMPORTANT: Spawn as server-owned so server can modify worker's NetworkVariables
|
||||
workerNetObj.Spawn();
|
||||
_lastSpawnTime = Time.time;
|
||||
_workerCount.Value++;
|
||||
|
||||
ShowSpawnEffectClientRpc(spawnPosition);
|
||||
ShowSpawnEffectClientRpc(spawnPosition);
|
||||
|
||||
Debug.Log($"[WorkerSpawner] 워커 생성됨 (총 워커: {_workerCount.Value}/{maxWorkers})");
|
||||
Debug.Log($"[WorkerSpawner] Worker spawned (server-owned) and assigned to player {playerId} (Total: {_workerCount.Value}/{maxWorkers})");
|
||||
|
||||
ScheduleWorkerAssignment(playerId, workerNetObj.NetworkObjectId);
|
||||
}
|
||||
ScheduleWorkerAssignment(playerId, workerNetObj.NetworkObjectId);
|
||||
}
|
||||
|
||||
private void ScheduleWorkerAssignment(ulong playerId, ulong workerNetObjectId)
|
||||
private void ScheduleWorkerAssignment(ulong playerId, ulong workerNetObjectId)
|
||||
{
|
||||
StartCoroutine(AssignWorkerAfterFrame(playerId, workerNetObjectId));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user