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

IsOwner is False on owning Client when spawning object during ConnectionApproval.

Ouverte
#3,802 2 commentaires 0 réactions 0 personnes assignées Voir sur GitHub

Personne n'a encore pris cette issue.

stat:awaiting-response stat:imported type:bug
Langage dominant
C#
Étoiles
2.3k
Forks
461
Merge moyen
3 j 16 h
PR mergées (30 j)
20

Description

Description

When spawning a Player object and a Player Owned object during Connection Approval, the Network Behaviors on the Clients GameObjects report IsOwner as being false, while the Network Object reports IsOwner as true.

It seems based on my repro project that the client receives the CreateObjectMessages for their Player and Owned object before their ConnectionApproved message. This causes the client to not have an assigned clientId so when the Network Behaviours initialze, they set IsOwner as false (Although, the Network Object seems to include IsOwner as part of its serialized data). My guess is that this is some kind of knock on from distributed authority being added to the library (I am 99% certain I have done what is happening in this repro here in other projects from a couple years ago...)

I think that the fix here (at least if I was to rework my code) would be to do all spawning once the connection is approved and once the client reports they are ready to get their objects (somehow)

I have included a small repro project with this report.

Reproduce Steps

Download the repro project.
ownership_issue_repro.zip

  1. Go to Scenes and open Bootstrap
  2. Click the MPPM dropdown near the play button and select "Client - Direct Connection"
  3. Click Play, and wait for the client to connect to the host.
  4. Find their Player(clone) or ClientObject(clone) object in the hierarchy, note that IsOwner is True on the Network Object.
  5. Switch inspector to Debug mode, and look at the IsOwner field on the attached network behaviors. Note that it is set to false.
  6. Additionally, note that some random network objects are in the hierarchy, which were never spawned.
Actual Outcome

Objects spawned during ConnectionApproval are incorrectly set as IsOwner = false;

Expected Outcome

Either an error / warning is called when spawning with ownership for a none approved client OR the spawn messages are only sent once the approval is complete and the client has their clientId

Environment
  • OS: Windows 11
  • Unity Version: 6000.0.60f1
  • Netcode Version: 2.7.0
  • Netcode Topology: Client-Server

Guide de contribution

Ouvrir le guide de contribution

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Piste de recherche

Commencez avec l’archive ownership_issue_repro.zip incluse et reproduisez le problème via la Bootstrap scene en utilisant la configuration Client - Direct Connection. Suivez ConnectionApproval, CreateObjectMessages, l’affectation de clientId et l’initialisation de Network Behavior ; le travail est terminé lorsque les objets générés pendant l’approbation indiquent une propriété cohérente, sans apparition d’objets non générés.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Évaluation

Stack technique
csharp, unity
Domaine
networking
Type d'issue
Bug
Difficulté
4/5
Temps estimé
3-5 jours
Activité
À l'abandon
Clarté
Plutôt claire
Accessibilité débutants
38/100

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.