NetworkShow and CheckObjectVisibility limiting visibiliy management flexibility (and does not work as intened in documentation)
@NoelStephensUnity is already working on this.
Since Oct 5, 2023.
Assessment
This issue has not been assessed yet.
Description
Is your feature request related to a problem? Please describe.
Using a NetworkShow and CheckObjectVisibility is known to be impossible, and there were already some discussions about it in the past (see https://github.com/Unity-Technologies/com.unity.netcode.gameobjects/issues/2546 and https://github.com/Unity-Technologies/com.unity.netcode.gameobjects/issues/2609 )
A resolution of the above issues was an introduction of SpawnWithObservers property on NetworkObject. That indeed solved situations where it was necessary to spawn object with no observers. However, in my case, I want to spawn a player object with owner-only visibility, and later add additional objects. However if I do it with:
go.GetComponent<NetworkObject>().CheckObjectVisibility = ((cId) =>
{
return cId == go.GetComponent<NetworkObject>().OwnerClientId;
});
It results in fully blocking me from any further network visibility management with NetworkShow / NetworkHide.
Interesting that the documentation tells that the above approach is actually valid:
https://docs-multiplayer.unity3d.com/netcode/current/basics/object-visibility/
It's said that CheckObjectVisibility is checked only at object spawn, and it's advised to use NetworkShow/NetworkHide after that. However currently it's not how it works, and it's necessary to both update the delegate method and do NetworkShow every time I need to show some object to some client. I feel there is a redundancy in updating a delegate in addition to NetworkShow.
Describe the solution you'd like
- Currently, in my local branch of NGO I just commented out a visibility check in
NetworkShowthat prevents the method from doing what is supposed to do. This is the fastest solution. - More beautiful solution would be to have a new argument to spawn a function to setup initial observes of the object:
SpawnAsPlayerObject(clientId, observers: new List<ulong>{.....});
Spawn(observers: new List<ulong>{.....});
- Or as it was proposed previously in https://github.com/Unity-Technologies/com.unity.netcode.gameobjects/issues/2546 some sort of new delegate such as
CheckObjectInitialVisibilitywould also fix the issue
- Dominant language
- C#
- Stars
- 2.3k
- Forks
- 461
- Avg merge
- 3d 16h
- Merged PRs (30d)
- 20
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from Unity-Technologies/com.unity.netcode.gameobjects
-
stat:awaiting-response stat:imported type:bug
Difficulty 4/5 3-5 days Newbie friendliness 68/100
Unity-Technologies/com.unity.netcode.gameobjects#4159 · 3 comments ·
-
stat:reply-needed type:support
Difficulty 4/5 3-5 days Newbie friendliness 55/100
Unity-Technologies/com.unity.netcode.gameobjects#4095 · 10 comments ·
-
stat:awaiting-triage stat:Investigating type:bug
Unity-Technologies/com.unity.netcode.gameobjects#3912 · 5 comments · 1 assignee ·
-
Tracking type:feature-2.x
Difficulty 5/5 Over a week Newbie friendliness 35/100
Unity-Technologies/com.unity.netcode.gameobjects#3870 · 5 comments ·
-
Tracking type:feature
Difficulty 4/5 3-5 days Newbie friendliness 48/100
Unity-Technologies/com.unity.netcode.gameobjects#3830 · 7 comments ·
All issues in Unity-Technologies/com.unity.netcode.gameobjects
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
nightscout/nocturne#1379 ·
-
priority-0
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
Difficulty 1/5 Under an hour Newbie friendliness 78/100
StackExchange/StackExchange.Redis#3249 ·
-
[Feat] 조합 영역 구분선 개선 Open
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
documentation
Difficulty 2/5 1-3 hours Newbie friendliness 72/100