Unity-Technologies / Unity-Technologies/com.unity.netcode.gameobjects

NetworkTransform misses sync when GameObject is re-enabled; add option for automatic reassertion

未關閉
#3,435 4 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

還沒有人認領這個 Issue。

priority:low stat:awaiting-response stat:imported type:feature type:feature-2.x type:support
主要語言
C#
星號
2.3k
分支
461
平均合併
3 天 16 小時
30 天內合併 PR
20

描述

Description
When using NetworkTransform in server-authoritative mode, if a NetworkObject is deactivated on clients (e.g. via SetActive(false) or scene streaming), any transform changes (e.g. via Teleport) made while it's inactive are not propagated to the client once it's re-enabled. This results in position mismatches, where the client sees the object at its old position while the server has already moved it.

There is no warning, and the desync is silent unless manually corrected.

Reproduction Steps
Spawn a server-authoritative NetworkObject with a NetworkTransform

Deactivate the object on all clients (via RPC or reparenting in a disabled object)

On the server, call Teleport(...) to move the object

Reactivate the object after a short delay

Observe: the client does not reflect the new position

Expected Behavior
Clients should receive the latest authoritative position of the object when it becomes active again.

Workarounds
Currently, we must:

Reapply Teleport() after reactivating the object, or

Use a coroutine to delay the teleport until the object is re-enabled, or

Use custom NetworkVariable logic or whatever boiler plate works instead of NetworkTransform

Suggested Fixes
Add a forceResyncOnEnable bool on NetworkTransform

Internally store the last known transform state, and resend it on reactivation

Or provide an OnNetworkObjectReenabled callback for developers to manually reassert state

貢獻指南

開啟貢獻指南

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

研究方向

從 NetworkObject 處於非作用中狀態時 NetworkTransform 對 Teleport 的伺服器權威處理開始,然後重現所描述的停用、移動和重新啟用序列。確定如何在重新啟用時重新套用最新的權威變換,並驗證用戶端無需第二次呼叫 Teleport 即可接收到更新後的位置。

由索引模型根據 Issue 內容生成。

評估

技術堆疊
csharp, unity
領域
networking
Issue 類型
缺陷
難度
4/5
預估耗時
3-5 天
活躍度
停滯
描述清晰度
基本清楚
新手友好度
35/100

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。