From 83d4157ac694f36eac621b03a17356812383d0d2 Mon Sep 17 00:00:00 2001 From: Tran Nguyen Phuong Date: Tue, 30 Jun 2026 21:19:19 +0700 Subject: [PATCH] update --- .idea/.idea.BABA_YAGA/.idea/workspace.xml | 65 ++++++++++++------- Assets/Prefabs/Nolan/Nolan.prefab | 16 +++++ .../Player Prototype/PlayerDataManager.prefab | 3 +- .../Network/FusionClientMovementBridge.cs | 25 +++++-- ProjectSettings/UnityConnectSettings.asset | 2 +- 5 files changed, 82 insertions(+), 29 deletions(-) diff --git a/.idea/.idea.BABA_YAGA/.idea/workspace.xml b/.idea/.idea.BABA_YAGA/.idea/workspace.xml index ec51234e..58e0be2e 100644 --- a/.idea/.idea.BABA_YAGA/.idea/workspace.xml +++ b/.idea/.idea.BABA_YAGA/.idea/workspace.xml @@ -3,10 +3,17 @@ + + + - + + + + + - { - "keyToString": { - "ModuleVcsDetector.initialDetectionPerformed": "true", - "RunOnceActivity.MCP Project settings loaded": "true", - "RunOnceActivity.ShowReadmeOnStart": "true", - "RunOnceActivity.TerminalTabsStorage.copyFrom.TerminalArrangementManager.252": "true", - "RunOnceActivity.git.unshallow": "true", - "RunOnceActivity.typescript.service.memoryLimit.init": "true", - "com.intellij.ml.llm.matterhorn.ej.ui.settings.DefaultModelSelectionForGA.v1": "true", - "git-widget-placeholder": "main", - "junie.onboarding.icon.badge.shown": "true", - "node.js.detected.package.eslint": "true", - "node.js.detected.package.tslint": "true", - "node.js.selected.package.eslint": "(autodetect)", - "node.js.selected.package.tslint": "(autodetect)", - "nodejs_package_manager_path": "npm", - "to.speed.mode.migration.done": "true", - "vue.rearranger.settings.migration": "true" + +}]]> + + - + - @@ -122,6 +142,7 @@ + diff --git a/Assets/Prefabs/Nolan/Nolan.prefab b/Assets/Prefabs/Nolan/Nolan.prefab index 6edcf9a1..c74b3e3d 100644 --- a/Assets/Prefabs/Nolan/Nolan.prefab +++ b/Assets/Prefabs/Nolan/Nolan.prefab @@ -13343,6 +13343,7 @@ GameObject: - component: {fileID: 5202821522363770394} - component: {fileID: 1486775676321644921} - component: {fileID: 8796553624329906391} + - component: {fileID: 433263687854393238} m_Layer: 31 m_Name: Nolan m_TagString: Untagged @@ -15127,6 +15128,7 @@ MonoBehaviour: NetworkedBehaviours: - {fileID: 1486775676321644921} - {fileID: 8796553624329906391} + - {fileID: 433263687854393238} ForceRemoteRenderTimeframe: 0 --- !u!114 &1486775676321644921 MonoBehaviour: @@ -15157,6 +15159,20 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 39343fbd597ed5947b34fa2777fa1b7c, type: 3} m_Name: m_EditorClassIdentifier: Assembly-CSharp::Hallucinate.Network.FusionClientMovementBridge +--- !u!114 &433263687854393238 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 3995187695885635779} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: b3d9934ebd60c9c4ea3e464b77fd7ae0, type: 3} + m_Name: + m_EditorClassIdentifier: Assembly-CSharp::PlayerDataManager + _Players: + _items: [] --- !u!1 &4047096238443104023 GameObject: m_ObjectHideFlags: 0 diff --git a/Assets/Prefabs/Player Prototype/PlayerDataManager.prefab b/Assets/Prefabs/Player Prototype/PlayerDataManager.prefab index 95bde44f..c2c34ced 100644 --- a/Assets/Prefabs/Player Prototype/PlayerDataManager.prefab +++ b/Assets/Prefabs/Player Prototype/PlayerDataManager.prefab @@ -46,7 +46,8 @@ MonoBehaviour: m_Name: m_EditorClassIdentifier: Assembly-CSharp::PlayerDataManager _Players: - _items: [] + _items: + - {} --- !u!114 &-7009574229380509654 MonoBehaviour: m_ObjectHideFlags: 0 diff --git a/Assets/Scripts/Network/FusionClientMovementBridge.cs b/Assets/Scripts/Network/FusionClientMovementBridge.cs index c832c4d0..55d43858 100644 --- a/Assets/Scripts/Network/FusionClientMovementBridge.cs +++ b/Assets/Scripts/Network/FusionClientMovementBridge.cs @@ -36,7 +36,8 @@ namespace Hallucinate.Network { // Because we passed State Authority to the client in BasicSpawner, // HasStateAuthority is true ONLY for the local player. - bool isLocal = Object.HasStateAuthority; + // Check HasInputAuthority as well so the client's character correctly activates input! + bool isLocal = Object.HasStateAuthority || Object.HasInputAuthority; if (isLocal) { @@ -75,15 +76,29 @@ namespace Hallucinate.Network public override void FixedUpdateNetwork() { - if (Object.HasStateAuthority) + // ONLY attempt to get input if we are the Host (StateAuthority) or the owning Client (InputAuthority). + // Calling GetInput on a Proxy (someone else's character) is what causes the GetTypeKey exception! + if (Object.HasStateAuthority || Object.HasInputAuthority) { if (GetInput(out var input)) { - SyncInput = input; + // Apply input locally so the Client's character actually moves predicted! + if (m_CharacterLocomotion != null) + { + m_CharacterLocomotion.InputVector = input.InputVector; + m_CharacterLocomotion.RawInputVector = input.RawInputVector; + m_CharacterLocomotion.DeltaRotation = input.DeltaRotation; + } + + if (Object.HasStateAuthority) + { + SyncInput = input; + } } } - if (!Object.HasStateAuthority) + // If we do NOT have StateAuthority AND we do NOT have InputAuthority, it's a Proxy (remote player). + if (Object.IsProxy) { // Ensure look source is attached for remote players if (m_CharacterLocomotion != null && m_CharacterLocomotion.LookSource != (ILookSource)this) @@ -206,7 +221,7 @@ namespace Hallucinate.Network // --- INetworkInfo Implementation --- - public bool IsLocalPlayer() => Object.HasStateAuthority; + public bool IsLocalPlayer() => Object.HasStateAuthority || Object.HasInputAuthority; public bool IsServer() => Runner.IsServer; // Return FALSE because we are doing Client-Authoritative movement! diff --git a/ProjectSettings/UnityConnectSettings.asset b/ProjectSettings/UnityConnectSettings.asset index 029ad8b9..7a17e8f7 100644 --- a/ProjectSettings/UnityConnectSettings.asset +++ b/ProjectSettings/UnityConnectSettings.asset @@ -4,7 +4,7 @@ UnityConnectSettings: m_ObjectHideFlags: 0 serializedVersion: 1 - m_Enabled: 0 + m_Enabled: 1 m_TestMode: 0 m_EventOldUrl: https://api.uca.cloud.unity3d.com/v1/events m_EventUrl: https://cdp.cloud.unity3d.com/v1/events