Unity-Technologies / Unity-Technologies/com.unity.netcode.gameobjects
IsOwner is False on owning Client when spawning object during ConnectionApproval.
Chưa có ai nhận issue này.
- Ngôn ngữ chính
- C#
- Star
- 2.3k
- Fork
- 461
- Merge trung bình
- 3 ngày 16 giờ
- Pull request đã merge (30 ngày)
- 20
Mô tả
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
- Go to Scenes and open Bootstrap
- Click the MPPM dropdown near the play button and select "Client - Direct Connection"
- Click Play, and wait for the client to connect to the host.
- Find their Player(clone) or ClientObject(clone) object in the hierarchy, note that IsOwner is True on the Network Object.
- Switch inspector to Debug mode, and look at the IsOwner field on the attached network behaviors. Note that it is set to false.
- 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
Hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Hướng nghiên cứu
Bắt đầu với ownership_issue_repro.zip được cung cấp và tái hiện vấn đề thông qua Bootstrap scene bằng thiết lập Client - Direct Connection. Theo dõi ConnectionApproval, CreateObjectMessages, việc gán clientId và quá trình khởi tạo Network Behavior; được xem là hoàn tất khi các đối tượng được spawn trong quá trình phê duyệt báo cáo quyền sở hữu nhất quán mà không xuất hiện các đối tượng chưa được spawn.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- csharp, unity
- Lĩnh vực
- networking
- Loại issue
- Lỗi
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức độ hoạt động
- Đình trệ
- Độ rõ ràng
- Khá rõ ràng
- Mức phù hợp với người mới
- 38/100