fix: 플레이어 스폰 위치 중복 문제 해결 — Round-Robin 순차 할당 도입
- PlayerSpawnPoint.GetRandomSpawnPoint()을 랜덤에서 Round-Robin 순차 할당으로 변경 - 접속 순서대로 스폰 포인트를 순환하며 중복 스폰 방지 - BalanceDummy 씬에 두 번째 스폰 포인트 추가 (x=-5, y=3, z=0)
This commit is contained in:
@@ -4324,6 +4324,51 @@ PrefabInstance:
|
||||
m_AddedGameObjects: []
|
||||
m_AddedComponents: []
|
||||
m_SourcePrefab: {fileID: 100100000, guid: bf62c127a7934334d9b955503391f574, type: 3}
|
||||
--- !u!1 &808329368
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 808329370}
|
||||
- component: {fileID: 808329369}
|
||||
m_Layer: 0
|
||||
m_Name: SpawnPoint (2)
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!114 &808329369
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 808329368}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: aba9a2eb2571da14d901ed51c8866f47, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier: Colosseum.Game::Colosseum.Network.PlayerSpawnPoint
|
||||
useRotation: 1
|
||||
--- !u!4 &808329370
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 808329368}
|
||||
serializedVersion: 2
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: -5, y: 3, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children: []
|
||||
m_Father: {fileID: 0}
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!4 &817798737 stripped
|
||||
Transform:
|
||||
m_CorrespondingSourceObject: {fileID: 1824081129582740912, guid: bf62c127a7934334d9b955503391f574, type: 3}
|
||||
@@ -13610,3 +13655,4 @@ SceneRoots:
|
||||
- {fileID: 1108135668}
|
||||
- {fileID: 6925510005455365094}
|
||||
- {fileID: 1793508636}
|
||||
- {fileID: 808329370}
|
||||
|
||||
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user