NetworkShow and CheckObjectVisibility limiting visibiliy management flexibility (and does not work as intened in documentation)
@NoelStephensUnity y travaille déjà.
Depuis le 5/10/2023.
Évaluation
Cette issue n'a pas encore été évaluée.
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
- Langage dominant
- C#
- Étoiles
- 2.3k
- Forks
- 461
- Merge moyen
- 3 j 16 h
- PR mergées (30 j)
- 20
Guide de contribution
Ouvrir le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Autres issues de Unity-Technologies/com.unity.netcode.gameobjects
-
stat:import type:bug
Difficulté 4/5 3-5 jours Accessibilité débutants 68/100
-
stat:reply-needed type:support
Difficulté 4/5 3-5 jours Accessibilité débutants 55/100
Unity-Technologies/com.unity.netcode.gameobjects#4095 · 10 commentaires ·
-
stat:awaiting-triage stat:Investigating type:bug
Unity-Technologies/com.unity.netcode.gameobjects#3912 · 5 commentaires · 1 personne assignée ·
-
Tracking type:feature-2.x
Difficulté 5/5 Plus d'une semaine Accessibilité débutants 35/100
Unity-Technologies/com.unity.netcode.gameobjects#3870 · 5 commentaires ·
-
Please error, or at least warn, when a managed type is included in INetworkSerializeByMemcpy OuverteTracking type:feature
Difficulté 4/5 3-5 jours Accessibilité débutants 48/100
Unity-Technologies/com.unity.netcode.gameobjects#3830 · 7 commentaires ·
Toutes les issues de Unity-Technologies/com.unity.netcode.gameobjects
Issues similaires
-
bug
Difficulté 1/5 Moins d'une heure Accessibilité débutants 75/100
sillsdev/languageforge-lexbox#2665 ·
-
bug documentation frontend
Difficulté 2/5 1-3 heures Accessibilité débutants 72/100
azurenoops/spin_agent#975 ·
-
Difficulté 2/5 1-3 heures Accessibilité débutants 86/100
-
:watch: Not Triaged 11.0 fundamentals/subsvc
Difficulté 2/5 1-3 heures Accessibilité débutants 92/100
dotnet/AspNetCore.Docs#37699 ·
-
Difficulté 2/5 1-3 heures Accessibilité débutants 72/100
SubtitleEdit/subtitleedit#15108 · 1 commentaire ·