add unity project for networking

This commit is contained in:
2025-06-12 07:31:31 +02:00
parent b96ef0b9cb
commit 5a6d0a497a
163 changed files with 77011 additions and 0 deletions
+26
View File
@@ -0,0 +1,26 @@
using System.Collections.Generic;
using Unity.Netcode;
using UnityEngine;
namespace DefaultNamespace
{
public class GameManager : NetworkBehaviour
{
[SerializeField] private NetworkObject playerPrefab;
[SerializeField] private Transform[] startPositions;
private int _currentStartPositionIndex = 0;
protected override void OnInSceneObjectsSpawned()
{
if (!IsServer) return;
foreach (KeyValuePair<ulong, NetworkClient> client in NetworkManager.ConnectedClients)
{
Transform position = startPositions[_currentStartPositionIndex++ % startPositions.Length];
NetworkObject player = Instantiate(playerPrefab, position.position, position.rotation);
player.SpawnAsPlayerObject(client.Key);
}
}
}
}