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

`NetworkObject` `CheckObjectVisibility` doesn't work on client connection

未关闭
#3,185 6 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

Tracking type:docs type:support
主要语言
C#
星标
2.3k
派生
461
平均合并
3 天 16 小时
30 天内合并 PR
20

描述

Description

I want to spawn a networkprefab without any client visibility, first i tried to set no observers before spawn:

NetworkObject.SpawnWithObservers = false;
NetworkObject.Spawn();

this results a spawned object with zero observers, but when a late-join client connects, the object gets spawned on client. The documentation says this is the intended normal behavior, because it only works at the initial spawning.

Then, the documentation says the CheckObjectVisibility will work at both initial spawning and new client connection, so i tried this:

NetworkObject.CheckObjectVisibility += _ => false;
NetworkObject.Spawn();

it did spawn with no observers as the previous approach, but when late-join client connects, it still spawn the object on client.

Reproduce Steps
  1. start server/host
  2. spawn a network prefab with NetworkObject.CheckObjectVisibility += _ => false;
  3. start a client and connect to server
Actual Outcome

a spawned object with visibility always set to false still spawns on late-join client

Expected Outcome

a spawned object with visibility always set to false should be invisible to all connected client and future late-join clients

Environment
  • OS: [win10]
  • Unity Version: [6000.0.32f1]
  • Netcode Version: [2.1.1]

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

调研方向

从 NetworkObject 的 SpawnWithObservers、Spawn 和 CheckObjectVisibility 行为入手,对比报告中链接的 spawning 和对象可见性文档。复现 CheckObjectVisibility 返回 false 时的 late-join 序列,并确认对象在客户端上仍然不存在;完成标准是可见性也会对未来 late-join 的客户端生效。

由索引模型根据 Issue 内容生成。

评估

技术栈
csharp, unity
领域
game-dev, networking
Issue 类型
缺陷
难度
4/5
预计耗时
3-5 天
活跃度
停滞
描述清晰度
基本清楚
新手友好度
42/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。