Unity-Technologies / Unity-Technologies/com.unity.netcode.gameobjects
IsOwner is False on owning Client when spawning object during ConnectionApproval.
還沒有人認領這個 Issue。
- 主要語言
- C#
- 星號
- 2.3k
- 分支
- 461
- 平均合併
- 3 天 16 小時
- 30 天內合併 PR
- 20
描述
Description
When spawning a Player object and a Player Owned object during Connection Approval, the Network Behaviors on the Clients GameObjects report IsOwner as being false, while the Network Object reports IsOwner as true.
It seems based on my repro project that the client receives the CreateObjectMessages for their Player and Owned object before their ConnectionApproved message. This causes the client to not have an assigned clientId so when the Network Behaviours initialze, they set IsOwner as false (Although, the Network Object seems to include IsOwner as part of its serialized data). My guess is that this is some kind of knock on from distributed authority being added to the library (I am 99% certain I have done what is happening in this repro here in other projects from a couple years ago...)
I think that the fix here (at least if I was to rework my code) would be to do all spawning once the connection is approved and once the client reports they are ready to get their objects (somehow)
I have included a small repro project with this report.
Reproduce Steps
Download the repro project.
ownership_issue_repro.zip
- Go to Scenes and open Bootstrap
- Click the MPPM dropdown near the play button and select "Client - Direct Connection"
- Click Play, and wait for the client to connect to the host.
- Find their Player(clone) or ClientObject(clone) object in the hierarchy, note that IsOwner is True on the Network Object.
- Switch inspector to Debug mode, and look at the IsOwner field on the attached network behaviors. Note that it is set to false.
- Additionally, note that some random network objects are in the hierarchy, which were never spawned.
Actual Outcome
Objects spawned during ConnectionApproval are incorrectly set as IsOwner = false;
Expected Outcome
Either an error / warning is called when spawning with ownership for a none approved client OR the spawn messages are only sent once the approval is complete and the client has their clientId
Environment
- OS: Windows 11
- Unity Version: 6000.0.60f1
- Netcode Version: 2.7.0
- Netcode Topology: Client-Server
貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
研究方向
從隨附的 ownership_issue_repro.zip 開始,使用 Client - Direct Connection 設定透過 Bootstrap scene 重現問題。追蹤 ConnectionApproval、CreateObjectMessages、clientId 指派,以及 Network Behavior 初始化;完成的條件是,在核准期間產生的物件回報一致的擁有權,且不會出現未產生的物件。
由索引模型根據 Issue 內容生成。
評估
- 技術堆疊
- csharp, unity
- 領域
- networking
- Issue 類型
- 缺陷
- 難度
- 4/5
- 預估耗時
- 3-5 天
- 活躍度
- 停滯
- 描述清晰度
- 基本清楚
- 新手友好度
- 38/100