fix: 플레이어 스폰 위치 중복 문제 해결 — Round-Robin 순차 할당 도입

- PlayerSpawnPoint.GetRandomSpawnPoint()을 랜덤에서 Round-Robin 순차 할당으로 변경
- 접속 순서대로 스폰 포인트를 순환하며 중복 스폰 방지
- BalanceDummy 씬에 두 번째 스폰 포인트 추가 (x=-5, y=3, z=0)
This commit is contained in:
2026-03-28 21:18:07 +09:00
parent 282e4b29c4
commit dea7fd39ec
2 changed files with 58 additions and 4 deletions

View File

@@ -5,13 +5,15 @@ namespace Colosseum.Network
/// <summary>
/// 플레이어 스폰 위치 마커
/// 씬에 배치하여 플레이어가 스폰될 위치를 지정
/// Round-Robin 순차 할당으로 중복 스폰 방지
/// </summary>
public class PlayerSpawnPoint : MonoBehaviour
{
[Header("Spawn Settings")]
[SerializeField] private bool useRotation = true;
private static System.Collections.Generic.List<PlayerSpawnPoint> spawnPoints = new System.Collections.Generic.List<PlayerSpawnPoint>();
private static readonly System.Collections.Generic.List<PlayerSpawnPoint> spawnPoints = new System.Collections.Generic.List<PlayerSpawnPoint>();
private static int nextSpawnIndex;
private void Awake()
{
@@ -24,17 +26,23 @@ namespace Colosseum.Network
}
/// <summary>
/// 사용 가능한 스폰 포인트 중 하나를 반환
/// Round-Robin 순차 할당 — 접속 순서대로 순환하며 중복 없이 반환
/// </summary>
public static Transform GetRandomSpawnPoint()
public static Transform GetNextSpawnPoint()
{
if (spawnPoints.Count == 0)
return null;
int index = Random.Range(0, spawnPoints.Count);
int index = nextSpawnIndex % spawnPoints.Count;
nextSpawnIndex++;
return spawnPoints[index].transform;
}
/// <summary>
/// 사용 가능한 스폰 포인트 중 하나를 반환 (기존 호환용, 내부적으로 Round-Robin 사용)
/// </summary>
public static Transform GetRandomSpawnPoint() => GetNextSpawnPoint();
/// <summary>
/// 스폰 포인트 개수 반환
/// </summary>