플레이어 스폰 포인트 기능 오류 수정 및 기본 오브젝트 배치 수정
This commit is contained in:
@@ -19,13 +19,13 @@ MonoBehaviour:
|
|||||||
SourcePrefabToOverride: {fileID: 0}
|
SourcePrefabToOverride: {fileID: 0}
|
||||||
SourceHashToOverride: 0
|
SourceHashToOverride: 0
|
||||||
OverridingTargetPrefab: {fileID: 0}
|
OverridingTargetPrefab: {fileID: 0}
|
||||||
- Override: 0
|
|
||||||
Prefab: {fileID: 3733880183385667081, guid: 1979909431408184b9bc587877c5b4b4, type: 3}
|
|
||||||
SourcePrefabToOverride: {fileID: 0}
|
|
||||||
SourceHashToOverride: 0
|
|
||||||
OverridingTargetPrefab: {fileID: 0}
|
|
||||||
- Override: 0
|
- Override: 0
|
||||||
Prefab: {fileID: 5585059388146411250, guid: f395fcc064a3a834ba957327f1387c19, type: 3}
|
Prefab: {fileID: 5585059388146411250, guid: f395fcc064a3a834ba957327f1387c19, type: 3}
|
||||||
SourcePrefabToOverride: {fileID: 0}
|
SourcePrefabToOverride: {fileID: 0}
|
||||||
SourceHashToOverride: 0
|
SourceHashToOverride: 0
|
||||||
OverridingTargetPrefab: {fileID: 0}
|
OverridingTargetPrefab: {fileID: 0}
|
||||||
|
- Override: 0
|
||||||
|
Prefab: {fileID: 4631342387095849626, guid: 5662d0b0d0eb5f54290edd8dd0980b57, type: 3}
|
||||||
|
SourcePrefabToOverride: {fileID: 0}
|
||||||
|
SourceHashToOverride: 0
|
||||||
|
OverridingTargetPrefab: {fileID: 0}
|
||||||
|
|||||||
@@ -223672,9 +223672,9 @@ Material:
|
|||||||
- _OutlineWidth: 0
|
- _OutlineWidth: 0
|
||||||
- _PerspectiveFilter: 0.875
|
- _PerspectiveFilter: 0.875
|
||||||
- _Reflectivity: 10
|
- _Reflectivity: 10
|
||||||
- _ScaleRatioA: 0.85714287
|
- _ScaleRatioA: 0
|
||||||
- _ScaleRatioB: 0.6964286
|
- _ScaleRatioB: 0
|
||||||
- _ScaleRatioC: 0.6964286
|
- _ScaleRatioC: 0
|
||||||
- _ScaleX: 1
|
- _ScaleX: 1
|
||||||
- _ScaleY: 1
|
- _ScaleY: 1
|
||||||
- _ShaderFlags: 0
|
- _ShaderFlags: 0
|
||||||
|
|||||||
76
Assets/Prefabs/PlayerSpawnPoint.prefab
Normal file
76
Assets/Prefabs/PlayerSpawnPoint.prefab
Normal file
@@ -0,0 +1,76 @@
|
|||||||
|
%YAML 1.1
|
||||||
|
%TAG !u! tag:unity3d.com,2011:
|
||||||
|
--- !u!1 &4631342387095849626
|
||||||
|
GameObject:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
serializedVersion: 6
|
||||||
|
m_Component:
|
||||||
|
- component: {fileID: 922888705413710451}
|
||||||
|
- component: {fileID: 2586844881002566986}
|
||||||
|
- component: {fileID: 133850760071591855}
|
||||||
|
m_Layer: 0
|
||||||
|
m_Name: PlayerSpawnPoint
|
||||||
|
m_TagString: Untagged
|
||||||
|
m_Icon: {fileID: 0}
|
||||||
|
m_NavMeshLayer: 0
|
||||||
|
m_StaticEditorFlags: 0
|
||||||
|
m_IsActive: 1
|
||||||
|
--- !u!4 &922888705413710451
|
||||||
|
Transform:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 4631342387095849626}
|
||||||
|
serializedVersion: 2
|
||||||
|
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||||
|
m_LocalPosition: {x: -3, y: 0, z: -5}
|
||||||
|
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!114 &2586844881002566986
|
||||||
|
MonoBehaviour:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 4631342387095849626}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_EditorHideFlags: 0
|
||||||
|
m_Script: {fileID: 11500000, guid: 41a3c6ef0dc9b4d4c9db4ec668a78fb3, type: 3}
|
||||||
|
m_Name:
|
||||||
|
m_EditorClassIdentifier: Assembly-CSharp::Northbound.PlayerSpawnPoint
|
||||||
|
spawnIndex: 0
|
||||||
|
isAvailable: 1
|
||||||
|
gizmoColor: {r: 0, g: 1, b: 0, a: 1}
|
||||||
|
gizmoRadius: 0.5
|
||||||
|
--- !u!114 &133850760071591855
|
||||||
|
MonoBehaviour:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 4631342387095849626}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_EditorHideFlags: 0
|
||||||
|
m_Script: {fileID: 11500000, guid: d5a57f767e5e46a458fc5d3c628d0cbb, type: 3}
|
||||||
|
m_Name:
|
||||||
|
m_EditorClassIdentifier: Unity.Netcode.Runtime::Unity.Netcode.NetworkObject
|
||||||
|
GlobalObjectIdHash: 2078657082
|
||||||
|
InScenePlacedSourceGlobalObjectIdHash: 0
|
||||||
|
DeferredDespawnTick: 0
|
||||||
|
Ownership: 1
|
||||||
|
AlwaysReplicateAsRoot: 0
|
||||||
|
SynchronizeTransform: 1
|
||||||
|
ActiveSceneSynchronization: 0
|
||||||
|
SceneMigrationSynchronization: 0
|
||||||
|
SpawnWithObservers: 1
|
||||||
|
DontDestroyWithOwner: 0
|
||||||
|
AutoObjectParentSync: 1
|
||||||
|
SyncOwnerTransformWhenParented: 1
|
||||||
|
AllowOwnerToParent: 0
|
||||||
7
Assets/Prefabs/PlayerSpawnPoint.prefab.meta
Normal file
7
Assets/Prefabs/PlayerSpawnPoint.prefab.meta
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 5662d0b0d0eb5f54290edd8dd0980b57
|
||||||
|
PrefabImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -18,17 +18,25 @@ namespace Northbound
|
|||||||
private Dictionary<ulong, int> _clientSpawnIndices = new Dictionary<ulong, int>();
|
private Dictionary<ulong, int> _clientSpawnIndices = new Dictionary<ulong, int>();
|
||||||
private int _nextSpawnIndex = 0;
|
private int _nextSpawnIndex = 0;
|
||||||
|
|
||||||
private void Start()
|
// ⭐ Awake에서 스폰 포인트 먼저 찾고, 콜백 등록
|
||||||
|
private void Awake()
|
||||||
{
|
{
|
||||||
|
// 1️⃣ 먼저 스폰 포인트 찾기
|
||||||
if (findSpawnPointsAutomatically)
|
if (findSpawnPointsAutomatically)
|
||||||
{
|
{
|
||||||
FindSpawnPoints();
|
FindSpawnPoints();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 2️⃣ 그 다음 콜백 등록
|
||||||
if (NetworkManager.Singleton != null)
|
if (NetworkManager.Singleton != null)
|
||||||
{
|
{
|
||||||
NetworkManager.Singleton.ConnectionApprovalCallback = ApprovalCheck;
|
NetworkManager.Singleton.ConnectionApprovalCallback = ApprovalCheck;
|
||||||
NetworkManager.Singleton.OnServerStarted += OnServerStarted;
|
NetworkManager.Singleton.OnServerStarted += OnServerStarted;
|
||||||
|
Debug.Log("<color=cyan>[Connection] ConnectionApprovalCallback 등록됨</color>");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Debug.LogError("[Connection] NetworkManager.Singleton이 null입니다!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -60,6 +68,12 @@ namespace Northbound
|
|||||||
NetworkManager.ConnectionApprovalRequest request,
|
NetworkManager.ConnectionApprovalRequest request,
|
||||||
NetworkManager.ConnectionApprovalResponse response)
|
NetworkManager.ConnectionApprovalResponse response)
|
||||||
{
|
{
|
||||||
|
// 🔍 디버깅: 스폰 포인트 상태 확인
|
||||||
|
if (spawnPoints.Count == 0)
|
||||||
|
{
|
||||||
|
Debug.LogError($"<color=red>[Connection] 스폰 포인트가 없습니다! 씬에 PlayerSpawnPoint가 있는지 확인하세요.</color>");
|
||||||
|
}
|
||||||
|
|
||||||
response.Approved = true;
|
response.Approved = true;
|
||||||
response.CreatePlayerObject = true;
|
response.CreatePlayerObject = true;
|
||||||
|
|
||||||
@@ -67,7 +81,7 @@ namespace Northbound
|
|||||||
response.Position = GetSpawnPosition(request.ClientNetworkId);
|
response.Position = GetSpawnPosition(request.ClientNetworkId);
|
||||||
response.Rotation = GetSpawnRotation(request.ClientNetworkId);
|
response.Rotation = GetSpawnRotation(request.ClientNetworkId);
|
||||||
|
|
||||||
Debug.Log($"<color=cyan>[Connection] 클라이언트 {request.ClientNetworkId} 승인됨. 스폰 위치: {response.Position}</color>");
|
Debug.Log($"<color=green>[Connection] 클라이언트 {request.ClientNetworkId} 승인됨. 스폰 위치: {response.Position}</color>");
|
||||||
}
|
}
|
||||||
|
|
||||||
private Vector3 GetSpawnPosition(ulong clientId)
|
private Vector3 GetSpawnPosition(ulong clientId)
|
||||||
@@ -94,6 +108,7 @@ namespace Northbound
|
|||||||
spawnIndex = _clientSpawnIndices[clientId];
|
spawnIndex = _clientSpawnIndices[clientId];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Debug.Log($"<color=yellow>[Connection] 클라이언트 {clientId}에게 스폰 인덱스 {spawnIndex} 할당</color>");
|
||||||
return spawnPoints[spawnIndex].position;
|
return spawnPoints[spawnIndex].position;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user