Unity-Technologies / Unity-Technologies/com.unity.netcode.gameobjects
NetworkTransform misses sync when GameObject is re-enabled; add option for automatic reassertion
还没有人认领这个 Issue。
- 主要语言
- 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
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
从 NetworkObject 处于非活动状态时 NetworkTransform 对 Teleport 的服务器权威处理开始,然后重现所描述的禁用、移动和重新启用序列。确定如何在重新激活时重新应用最新的权威变换,并验证客户端无需第二次调用 Teleport 即可接收到更新后的位置。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- csharp, unity
- 领域
- networking
- Issue 类型
- 缺陷
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 活跃度
- 停滞
- 描述清晰度
- 基本清楚
- 新手友好度
- 35/100