diff --git a/.idea/.idea.BABA_YAGA/.idea/workspace.xml b/.idea/.idea.BABA_YAGA/.idea/workspace.xml index 489ad370..9dc5246a 100644 --- a/.idea/.idea.BABA_YAGA/.idea/workspace.xml +++ b/.idea/.idea.BABA_YAGA/.idea/workspace.xml @@ -12,17 +12,11 @@ - - - - - - - - + + diff --git a/Assets/Scenes/Main Scene.unity b/Assets/Scenes/Main Scene.unity index c5290a73..a8fa2273 100644 --- a/Assets/Scenes/Main Scene.unity +++ b/Assets/Scenes/Main Scene.unity @@ -276,12 +276,12 @@ Transform: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 786488} serializedVersion: 2 - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: 3.5546, y: -5.79626, z: 4.39807} m_LocalScale: {x: 1, y: 1, z: 1} m_ConstrainProportionsScale: 0 m_Children: [] - m_Father: {fileID: 0} + m_Father: {fileID: 656189834} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!1 &346257371 GameObject: @@ -293,7 +293,7 @@ GameObject: m_Component: - component: {fileID: 346257372} m_Layer: 0 - m_Name: _MAP + m_Name: Map m_TagString: Untagged m_Icon: {fileID: 0} m_NavMeshLayer: 0 @@ -317,6 +317,23 @@ Transform: - {fileID: 1100452909} m_Father: {fileID: 656189834} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!1 &559571013 stripped +GameObject: + m_CorrespondingSourceObject: {fileID: 3920157385471253802, guid: 65ca090fdbcb6fe418518ecc53625855, type: 3} + m_PrefabInstance: {fileID: 1216657555} + m_PrefabAsset: {fileID: 0} +--- !u!114 &559571021 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 559571013} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 39343fbd597ed5947b34fa2777fa1b7c, type: 3} + m_Name: + m_EditorClassIdentifier: Assembly-CSharp::Hallucinate.Network.FusionClientMovementBridge --- !u!1 &598933323 GameObject: m_ObjectHideFlags: 0 @@ -454,7 +471,7 @@ GameObject: m_Component: - component: {fileID: 620725564} m_Layer: 0 - m_Name: _Enviroment + m_Name: Enviroment m_TagString: Untagged m_Icon: {fileID: 0} m_NavMeshLayer: 0 @@ -505,6 +522,7 @@ Transform: m_LocalScale: {x: 1, y: 1, z: 1} m_ConstrainProportionsScale: 0 m_Children: + - {fileID: 786498} - {fileID: 346257372} - {fileID: 620725564} m_Father: {fileID: 0} @@ -518,11 +536,11 @@ GameObject: serializedVersion: 6 m_Component: - component: {fileID: 747234400} - - component: {fileID: 747234402} - - component: {fileID: 747234401} + - component: {fileID: 747234405} - component: {fileID: 747234403} + - component: {fileID: 747234404} m_Layer: 0 - m_Name: _PlayerDataManger + m_Name: Network Manager m_TagString: Untagged m_Icon: {fileID: 0} m_NavMeshLayer: 0 @@ -543,39 +561,6 @@ Transform: m_Children: [] m_Father: {fileID: 751090087} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!114 &747234401 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 747234399} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: -1552182283, guid: e725a070cec140c4caffb81624c8c787, type: 3} - m_Name: - m_EditorClassIdentifier: Fusion.Runtime.dll::Fusion.NetworkObject - SortKey: 2253434107 - ObjectInterest: 1 - Flags: 262145 - NestedObjects: [] - NetworkedBehaviours: - - {fileID: 747234402} - ForceRemoteRenderTimeframe: 0 ---- !u!114 &747234402 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 747234399} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: b3d9934ebd60c9c4ea3e464b77fd7ae0, type: 3} - m_Name: - m_EditorClassIdentifier: Assembly-CSharp::_PlayerDataManager - _Players: - _items: [] --- !u!114 &747234403 MonoBehaviour: m_ObjectHideFlags: 0 @@ -592,6 +577,33 @@ MonoBehaviour: RawGuidValue: 78cdc99d2fb73904586ae402e642e288 _playerDataManagerPrefab: RawGuidValue: 33a4edcf030b02446bd8e4bb9a0fb9f3 +--- !u!114 &747234404 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 747234399} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 90a93abf1a391964a94e5c139605105b, type: 3} + m_Name: + m_EditorClassIdentifier: Fusion.Unity::Fusion.NetworkSceneManagerDefault + IsSceneTakeOverEnabled: 1 + LogSceneLoadErrors: 1 + DestroySpawnedPrefabsOnSceneUnload: 1 +--- !u!114 &747234405 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 747234399} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: -1199893898, guid: e725a070cec140c4caffb81624c8c787, type: 3} + m_Name: + m_EditorClassIdentifier: Fusion.Runtime.dll::Fusion.NetworkRunner --- !u!1 &751090086 GameObject: m_ObjectHideFlags: 0 @@ -671,91 +683,16 @@ Transform: - {fileID: 1052820475} m_Father: {fileID: 346257372} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!1001 &834444804 -PrefabInstance: - m_ObjectHideFlags: 0 - serializedVersion: 2 - m_Modification: - serializedVersion: 3 - m_TransformParent: {fileID: 0} - m_Modifications: - - target: {fileID: 3995187695885635779, guid: 78cdc99d2fb73904586ae402e642e288, type: 3} - propertyPath: m_Name - value: Nolan - objectReference: {fileID: 0} - - target: {fileID: 3995187695885635779, guid: 78cdc99d2fb73904586ae402e642e288, type: 3} - propertyPath: m_IsActive - value: 1 - objectReference: {fileID: 0} - - target: {fileID: 3995187695885635779, guid: 78cdc99d2fb73904586ae402e642e288, type: 3} - propertyPath: m_TagString - value: Player - objectReference: {fileID: 0} - - target: {fileID: 5202821522363770394, guid: 78cdc99d2fb73904586ae402e642e288, type: 3} - propertyPath: Flags - value: 262145 - objectReference: {fileID: 0} - - target: {fileID: 5202821522363770394, guid: 78cdc99d2fb73904586ae402e642e288, type: 3} - propertyPath: SortKey - value: 2177442090 - objectReference: {fileID: 0} - - target: {fileID: 5202821522363770394, guid: 78cdc99d2fb73904586ae402e642e288, type: 3} - propertyPath: NetworkedBehaviours.Array.size - value: 2 - objectReference: {fileID: 0} - - target: {fileID: 5502406095437965837, guid: 78cdc99d2fb73904586ae402e642e288, type: 3} - propertyPath: m_Layer - value: 24 - objectReference: {fileID: 0} - - target: {fileID: 6021283563354449352, guid: 78cdc99d2fb73904586ae402e642e288, type: 3} - propertyPath: m_LocalPosition.x - value: 7.09449 - objectReference: {fileID: 0} - - target: {fileID: 6021283563354449352, guid: 78cdc99d2fb73904586ae402e642e288, type: 3} - propertyPath: m_LocalPosition.y - value: -0 - objectReference: {fileID: 0} - - target: {fileID: 6021283563354449352, guid: 78cdc99d2fb73904586ae402e642e288, type: 3} - propertyPath: m_LocalPosition.z - value: -0.76184 - objectReference: {fileID: 0} - - target: {fileID: 6021283563354449352, guid: 78cdc99d2fb73904586ae402e642e288, type: 3} - propertyPath: m_LocalRotation.w - value: 1 - objectReference: {fileID: 0} - - target: {fileID: 6021283563354449352, guid: 78cdc99d2fb73904586ae402e642e288, type: 3} - propertyPath: m_LocalRotation.x - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 6021283563354449352, guid: 78cdc99d2fb73904586ae402e642e288, type: 3} - propertyPath: m_LocalRotation.y - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 6021283563354449352, guid: 78cdc99d2fb73904586ae402e642e288, type: 3} - propertyPath: m_LocalRotation.z - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 6021283563354449352, guid: 78cdc99d2fb73904586ae402e642e288, type: 3} - propertyPath: m_LocalEulerAnglesHint.x - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 6021283563354449352, guid: 78cdc99d2fb73904586ae402e642e288, type: 3} - propertyPath: m_LocalEulerAnglesHint.y - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 6021283563354449352, guid: 78cdc99d2fb73904586ae402e642e288, type: 3} - propertyPath: m_LocalEulerAnglesHint.z - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 8245682524002939726, guid: 78cdc99d2fb73904586ae402e642e288, type: 3} - propertyPath: m_Layer - value: 24 - objectReference: {fileID: 0} - m_RemovedComponents: [] - m_RemovedGameObjects: [] - m_AddedGameObjects: [] - m_AddedComponents: [] - m_SourcePrefab: {fileID: 100100000, guid: 78cdc99d2fb73904586ae402e642e288, type: 3} +--- !u!224 &942362353 stripped +RectTransform: + m_CorrespondingSourceObject: {fileID: 224362287594313636, guid: b5bf2e4077598914b83fc5e4ca20f2f4, type: 3} + m_PrefabInstance: {fileID: 2136780664} + m_PrefabAsset: {fileID: 0} +--- !u!224 &1004365544 stripped +RectTransform: + m_CorrespondingSourceObject: {fileID: 224443155498923482, guid: 33d3d57ba5fc7484c8d09150e45066a4, type: 3} + m_PrefabInstance: {fileID: 1420512788} + m_PrefabAsset: {fileID: 0} --- !u!1 &1052820474 GameObject: m_ObjectHideFlags: 0 @@ -877,7 +814,7 @@ PrefabInstance: objectReference: {fileID: 0} - target: {fileID: 7418421637809006319, guid: 65ca090fdbcb6fe418518ecc53625855, type: 3} propertyPath: m_LocalPosition.z - value: 0.23689 + value: 0.23688984 objectReference: {fileID: 0} - target: {fileID: 7418421637809006319, guid: 65ca090fdbcb6fe418518ecc53625855, type: 3} propertyPath: m_LocalRotation.w @@ -885,15 +822,15 @@ PrefabInstance: objectReference: {fileID: 0} - target: {fileID: 7418421637809006319, guid: 65ca090fdbcb6fe418518ecc53625855, type: 3} propertyPath: m_LocalRotation.x - value: 0 + value: -0 objectReference: {fileID: 0} - target: {fileID: 7418421637809006319, guid: 65ca090fdbcb6fe418518ecc53625855, type: 3} propertyPath: m_LocalRotation.y - value: 0 + value: -0 objectReference: {fileID: 0} - target: {fileID: 7418421637809006319, guid: 65ca090fdbcb6fe418518ecc53625855, type: 3} propertyPath: m_LocalRotation.z - value: 0 + value: -0 objectReference: {fileID: 0} - target: {fileID: 7418421637809006319, guid: 65ca090fdbcb6fe418518ecc53625855, type: 3} propertyPath: m_LocalEulerAnglesHint.x @@ -910,7 +847,10 @@ PrefabInstance: m_RemovedComponents: [] m_RemovedGameObjects: [] m_AddedGameObjects: [] - m_AddedComponents: [] + m_AddedComponents: + - targetCorrespondingSourceObject: {fileID: 3920157385471253802, guid: 65ca090fdbcb6fe418518ecc53625855, type: 3} + insertIndex: -1 + addedObject: {fileID: 559571021} m_SourcePrefab: {fileID: 100100000, guid: 65ca090fdbcb6fe418518ecc53625855, type: 3} --- !u!1001 &1420512788 PrefabInstance: @@ -918,7 +858,7 @@ PrefabInstance: serializedVersion: 2 m_Modification: serializedVersion: 3 - m_TransformParent: {fileID: 0} + m_TransformParent: {fileID: 1945212510} m_Modifications: - target: {fileID: 1761879981998420, guid: 33d3d57ba5fc7484c8d09150e45066a4, type: 3} propertyPath: m_Name @@ -970,7 +910,7 @@ PrefabInstance: objectReference: {fileID: 0} - target: {fileID: 224443155498923482, guid: 33d3d57ba5fc7484c8d09150e45066a4, type: 3} propertyPath: m_LocalPosition.z - value: 0 + value: 9.42587 objectReference: {fileID: 0} - target: {fileID: 224443155498923482, guid: 33d3d57ba5fc7484c8d09150e45066a4, type: 3} propertyPath: m_LocalRotation.w @@ -990,11 +930,11 @@ PrefabInstance: objectReference: {fileID: 0} - target: {fileID: 224443155498923482, guid: 33d3d57ba5fc7484c8d09150e45066a4, type: 3} propertyPath: m_AnchoredPosition.x - value: 0 + value: -3.78801 objectReference: {fileID: 0} - target: {fileID: 224443155498923482, guid: 33d3d57ba5fc7484c8d09150e45066a4, type: 3} propertyPath: m_AnchoredPosition.y - value: 0 + value: 4.20374 objectReference: {fileID: 0} - target: {fileID: 224443155498923482, guid: 33d3d57ba5fc7484c8d09150e45066a4, type: 3} propertyPath: m_LocalEulerAnglesHint.x @@ -1126,13 +1066,46 @@ MeshFilter: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 1768466478} m_Mesh: {fileID: 10209, guid: 0000000000000000e000000000000000, type: 0} +--- !u!1 &1945212509 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1945212510} + m_Layer: 0 + m_Name: Player + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 0 +--- !u!4 &1945212510 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1945212509} + serializedVersion: 2 + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 3.78801, y: -4.20374, z: -9.42587} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: + - {fileID: 942362353} + - {fileID: 1004365544} + m_Father: {fileID: 0} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!1001 &2136780664 PrefabInstance: m_ObjectHideFlags: 0 serializedVersion: 2 m_Modification: serializedVersion: 3 - m_TransformParent: {fileID: 0} + m_TransformParent: {fileID: 1945212510} m_Modifications: - target: {fileID: 1814214236125630, guid: b5bf2e4077598914b83fc5e4ca20f2f4, type: 3} propertyPath: m_Name @@ -1192,7 +1165,7 @@ PrefabInstance: objectReference: {fileID: 0} - target: {fileID: 224362287594313636, guid: b5bf2e4077598914b83fc5e4ca20f2f4, type: 3} propertyPath: m_LocalPosition.z - value: 0 + value: 9.42587 objectReference: {fileID: 0} - target: {fileID: 224362287594313636, guid: b5bf2e4077598914b83fc5e4ca20f2f4, type: 3} propertyPath: m_LocalRotation.w @@ -1212,11 +1185,11 @@ PrefabInstance: objectReference: {fileID: 0} - target: {fileID: 224362287594313636, guid: b5bf2e4077598914b83fc5e4ca20f2f4, type: 3} propertyPath: m_AnchoredPosition.x - value: 0 + value: -3.78801 objectReference: {fileID: 0} - target: {fileID: 224362287594313636, guid: b5bf2e4077598914b83fc5e4ca20f2f4, type: 3} propertyPath: m_AnchoredPosition.y - value: 0 + value: 4.20374 objectReference: {fileID: 0} - target: {fileID: 224362287594313636, guid: b5bf2e4077598914b83fc5e4ca20f2f4, type: 3} propertyPath: m_LocalEulerAnglesHint.x @@ -1247,10 +1220,7 @@ PrefabInstance: SceneRoots: m_ObjectHideFlags: 0 m_Roots: - - {fileID: 786498} - {fileID: 751090087} - {fileID: 656189834} - - {fileID: 2136780664} - - {fileID: 834444804} - - {fileID: 1420512788} + - {fileID: 1945212510} - {fileID: 1216657555} diff --git a/Assets/Scripts/Network/BasicSpawner.cs b/Assets/Scripts/Network/BasicSpawner.cs index 14133bc4..fb1a7394 100644 --- a/Assets/Scripts/Network/BasicSpawner.cs +++ b/Assets/Scripts/Network/BasicSpawner.cs @@ -53,6 +53,46 @@ namespace Hallucinate.UI DontDestroyOnLoad(gameObject); } + private async void Start() + { + // Auto-connect if we bypass the UI and start directly in the Main Scene + if (UnityEngine.SceneManagement.SceneManager.GetActiveScene().name == "Main Scene") + { + Debug.Log("[BasicSpawner] Auto-starting Fusion in AutoHostOrClient mode for testing..."); + + if (_isStarting) return; + _isStarting = true; + + try + { + await EnsureRunnerExists(); + var sceneManager = gameObject.GetComponent(); + if (sceneManager == null) sceneManager = gameObject.AddComponent(); + + var result = await _runner.StartGame(new StartGameArgs() + { + GameMode = GameMode.Shared, + SessionName = "QuickTestRoom", // Hardcoded session for instant testing + SceneManager = sceneManager, + Scene = SceneRef.FromIndex(UnityEngine.SceneManagement.SceneManager.GetActiveScene().buildIndex) + }); + + if (result.Ok) + { + Debug.Log("[BasicSpawner] Auto Connect SUCCESS!"); + } + else + { + Debug.LogError($"[BasicSpawner] Auto Connect FAILED: {result.ShutdownReason}"); + } + } + finally + { + _isStarting = false; + } + } + } + public PlayerProfile LocalPlayerProfile { get; private set; } public void SetLocalPlayerProfile(PlayerProfile _profile) { @@ -91,8 +131,13 @@ namespace Hallucinate.UI if (this == null) return; // BasicSpawner itself might be destroyed - Debug.Log("[BasicSpawner] Creating new NetworkRunner component."); - _runner = gameObject.AddComponent(); + _runner = gameObject.GetComponent(); + if (_runner == null) + { + Debug.Log("[BasicSpawner] Creating new NetworkRunner component."); + _runner = gameObject.AddComponent(); + } + _runner.ProvideInput = true; _runner.AddCallbacks(this); } @@ -244,18 +289,13 @@ namespace Hallucinate.UI public void OnPlayerJoined(NetworkRunner runner, PlayerRef player) { + Debug.Log($"[BasicSpawner] PlayerJoined: {player.PlayerId}"); + + // In Shared Mode, there is no Server. Each client is responsible for spawning their own player. if (player == runner.LocalPlayer) { SendLocalMetaData(player); - } - - // If the server receives a player join event and the scene is already loaded, spawn them immediately - if (runner.IsServer && UnityEngine.SceneManagement.SceneManager.GetActiveScene().name == "Main Scene") - { - if (!_spawnedCharacters.ContainsKey(player)) - { - SpawnPlayer(runner, player); - } + SpawnPlayer(runner, player); } } @@ -434,9 +474,12 @@ namespace Hallucinate.UI private void SpawnPlayer(NetworkRunner runner, PlayerRef player) { + Debug.Log($"[BasicSpawner] Spawning Player {player.PlayerId} at {Time.time}"); Vector3 spawnPosition = (player == runner.LocalPlayer) ? new Vector3(-8, 2, 0) : new Vector3(8, 2, 0); var networkPlayerObject = runner.Spawn(_playerPrefab, spawnPosition, Quaternion.identity, player); + // In Shared Mode, runner.Spawn automatically grants State Authority to the caller. + // We just need to assign Input Authority. networkPlayerObject.AssignInputAuthority(player); _spawnedCharacters[player] = networkPlayerObject; diff --git a/Assets/Scripts/Network/FusionClientMovementBridge.cs b/Assets/Scripts/Network/FusionClientMovementBridge.cs index 683528f3..d50c0c59 100644 --- a/Assets/Scripts/Network/FusionClientMovementBridge.cs +++ b/Assets/Scripts/Network/FusionClientMovementBridge.cs @@ -10,32 +10,73 @@ namespace Hallucinate.Network { // Ensure Opsive components load before this [DefaultExecutionOrder(100)] - public class FusionClientMovementBridge : NetworkBehaviour, INetworkInfo, INetworkCharacter + public class FusionClientMovementBridge : NetworkBehaviour, INetworkInfo, INetworkCharacter, ILookSource { + // --- ILookSource Implementation (Dummy values for Proxy characters) --- + public GameObject GameObject => gameObject; + public Transform Transform => transform; + public float LookDirectionDistance => 100f; + public float Pitch => 0f; + public Vector3 LookPosition() => transform.position + Vector3.up * 1.5f; // Rough head height + public Vector3 LookDirection(bool characterLookDirection) => transform.forward; + public Vector3 LookDirection(Vector3 lookPosition, bool characterLookDirection, int layerMask, bool useRecoil) => transform.forward; + + private void Awake() + { + // Temporarily disable the Locomotion component so it unregisters from KinematicObjectManager. + // This prevents the frame-0 crash before we can safely attach the Look Source in Start(). + var loco = GetComponent(); + if (loco != null) loco.enabled = false; + + // MUST also disable the handler, otherwise it tries to update a disabled character (Index -1) + var handler = GetComponent(); + if (handler != null) handler.enabled = false; + } + + private void Start() + { + // Now that all Opsive components have finished Awake() and are fully initialized, + // we can safely attach the Look Source without causing NullReferenceExceptions in CharacterIK. + Opsive.Shared.Events.EventHandler.ExecuteEvent(gameObject, "OnCharacterAttachLookSource", this); + + // Re-enable Locomotion. It will run OnEnable() and safely register back to KinematicObjectManager. + var loco = GetComponent(); + if (loco != null) loco.enabled = true; + + // If Fusion has already spawned us, restore the handler for the local player + if (Object != null && Object.IsValid) + { + var handler = GetComponent(); + if (handler != null) handler.enabled = Object.HasInputAuthority; + } + } + public override void Spawned() { // We use InputAuthority to identify the local player because this is Host mode. bool isLocal = Object.HasInputAuthority; // 1. Isolate Input: Only the local player should read keyboard/mouse inputs. - var locoHandler = GetComponent(); - if (locoHandler != null) locoHandler.enabled = isLocal; - - var activeInput = GetComponent(); // Corrected class reference + var activeInput = GetComponent(); if (activeInput != null) activeInput.enabled = isLocal; - // 2. Isolate Camera: Only attach the camera if this is the local player. + // Safely enable the handler only if Locomotion is already enabled (to prevent index -1 crash) + var loco = GetComponent(); + var handler = GetComponent(); + if (handler != null && loco != null && loco.enabled) + { + handler.enabled = isLocal; + } + if (isLocal) { var cameraController = UnityEngine.Object.FindFirstObjectByType(); if (cameraController != null) { + cameraController.enabled = true; + // This will override our dummy LookSource with the actual Camera cameraController.Character = gameObject; } - - // CRITICAL: Disable NetworkTransform on the local client so Fusion doesn't pull the character back! - var nt = GetComponent(); - if (nt != null) nt.enabled = false; } } diff --git a/Assets/Third Parties/Photon/Fusion/Resources/PhotonAppSettings.asset b/Assets/Third Parties/Photon/Fusion/Resources/PhotonAppSettings.asset index cb5bf25a..296c5a76 100644 --- a/Assets/Third Parties/Photon/Fusion/Resources/PhotonAppSettings.asset +++ b/Assets/Third Parties/Photon/Fusion/Resources/PhotonAppSettings.asset @@ -13,7 +13,7 @@ MonoBehaviour: m_Name: PhotonAppSettings m_EditorClassIdentifier: Fusion.Realtime.dll::Fusion.Photon.Realtime.PhotonAppSettings AppSettings: - AppIdFusion: + AppIdFusion: 6ce8fd92-f5e0-40d8-aff0-efca6cdab6a1 AppIdChat: AppIdVoice: AppVersion: diff --git a/Assets/Third Parties/vHierarchy/vHierarchy Data.asset b/Assets/Third Parties/vHierarchy/vHierarchy Data.asset index 4c47894d..7004e2fc 100644 --- a/Assets/Third Parties/vHierarchy/vHierarchy Data.asset +++ b/Assets/Third Parties/vHierarchy/vHierarchy Data.asset @@ -16,6 +16,7 @@ MonoBehaviour: keys: - f6f338855ad36644f8143c150efa4089 - d7832b9a866cd1e4f8e997a9cf8f3647 + - eda5fe9b4dec586498dcf6d3f2e63088 values: - goDatas_byGlobalId: keys: @@ -59,3 +60,42 @@ MonoBehaviour: iconNameOrGuid: - colorIndex: 9 iconNameOrGuid: + - goDatas_byGlobalId: + keys: + - globalObjectIdString: GlobalObjectId_V1-2-eda5fe9b4dec586498dcf6d3f2e63088-751090086-0 + - globalObjectIdString: GlobalObjectId_V1-2-eda5fe9b4dec586498dcf6d3f2e63088-656189833-0 + - globalObjectIdString: GlobalObjectId_V1-2-eda5fe9b4dec586498dcf6d3f2e63088-1945212509-0 + - globalObjectIdString: GlobalObjectId_V1-2-eda5fe9b4dec586498dcf6d3f2e63088-3920157385471253802-1216657555 + - globalObjectIdString: GlobalObjectId_V1-2-eda5fe9b4dec586498dcf6d3f2e63088-1761879981998420-1420512788 + - globalObjectIdString: GlobalObjectId_V1-2-eda5fe9b4dec586498dcf6d3f2e63088-3995187695885635779-834444804 + - globalObjectIdString: GlobalObjectId_V1-2-eda5fe9b4dec586498dcf6d3f2e63088-1814214236125630-2136780664 + - globalObjectIdString: GlobalObjectId_V1-2-eda5fe9b4dec586498dcf6d3f2e63088-620725563-0 + - globalObjectIdString: GlobalObjectId_V1-2-eda5fe9b4dec586498dcf6d3f2e63088-346257371-0 + - globalObjectIdString: GlobalObjectId_V1-2-eda5fe9b4dec586498dcf6d3f2e63088-786488-0 + - globalObjectIdString: GlobalObjectId_V1-2-eda5fe9b4dec586498dcf6d3f2e63088-747234399-0 + - globalObjectIdString: GlobalObjectId_V1-2-eda5fe9b4dec586498dcf6d3f2e63088-598933323-0 + values: + - colorIndex: 9 + iconNameOrGuid: ScriptableObject Icon + - colorIndex: 8 + iconNameOrGuid: Terrain Icon + - colorIndex: 7 + iconNameOrGuid: AvatarMask On Icon + - colorIndex: 6 + iconNameOrGuid: Camera Icon + - colorIndex: 0 + iconNameOrGuid: ParticleSystem Icon + - colorIndex: 0 + iconNameOrGuid: AvatarMask On Icon + - colorIndex: 0 + iconNameOrGuid: ParticleSystem Icon + - colorIndex: 0 + iconNameOrGuid: Terrain Icon + - colorIndex: 0 + iconNameOrGuid: Terrain Icon + - colorIndex: 0 + iconNameOrGuid: StandaloneInputModule Icon + - colorIndex: 0 + iconNameOrGuid: LightmapParameters Icon + - colorIndex: 0 + iconNameOrGuid: Light Icon