Client NetworkObjects experience Awake, Start, OnEnable, and TriggerEnter, CollisionEnter at world 0,0,0 upon instantiation
@NoelStephensUnity đang làm issue này rồi.
Từ ngày 17/7/2025.
Đánh giá
Issue này chưa được đánh giá.
Mô tả
Description
When a client spawns a NetworkObject via NetworkSpawnManage.InstantiateNetworkPrefab() there is no position or rotation data passed into UnityEngine.Object.Instantiate() and therefore the object is created at world 0,0,0. On a later line of code the position and rotation are assigned, after instantiation.
This means Awake, Start, and OnEnable are all called when at world 0,0,0 -- this is arguably expected and why you have OnNetworkSpawn.
However, OnTriggerEnter (and probably OnCollisionEnter) also fire for things at world 0,0,0. That problem is outside of the scope of the OnNetworkSpawn warmup in my opinion.
Developers should not have to write custom code to handle this problem when the position and rotation could simply be passed into the instantiation.
internal NetworkObject InstantiateNetworkPrefab(GameObject networkPrefab, uint prefabGlobalObjectIdHash, Vector3? position, Quaternion? rotation)
{
Vector3 defaultPosition = position ?? Vector3.zero;
Quaternion defaultRotation = rotation ?? Quaternion.identity;
var networkObject = UnityEngine.Object.Instantiate(networkPrefab, defaultPosition, defaultRotation).GetComponent<NetworkObject>();
// networkObject.transform.position = position ?? networkObject.transform.position;
// networkObject.transform.rotation = rotation ?? networkObject.transform.rotation;
networkObject.NetworkManagerOwner = NetworkManager;
networkObject.PrefabGlobalObjectIdHash = prefabGlobalObjectIdHash;
return networkObject;
}
Environment
- OS: Windows 11
- Unity Version: 6000.1.3f1
- Netcode Version: 2.4.2
- Netcode Topology: Client-Server
- 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
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.
Issue khác của Unity-Technologies/com.unity.netcode.gameobjects
-
stat:import type:bug
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 68/100
-
stat:reply-needed type:support
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 55/100
Unity-Technologies/com.unity.netcode.gameobjects#4095 · 10 bình luận ·
-
stat:awaiting-triage stat:Investigating type:bug
Unity-Technologies/com.unity.netcode.gameobjects#3912 · 5 bình luận · 1 người được giao ·
-
Tracking type:feature-2.x
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 35/100
Unity-Technologies/com.unity.netcode.gameobjects#3870 · 5 bình luận ·
-
Please error, or at least warn, when a managed type is included in INetworkSerializeByMemcpy Đang mởTracking type:feature
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 48/100
Unity-Technologies/com.unity.netcode.gameobjects#3830 · 7 bình luận ·
Tất cả issue của Unity-Technologies/com.unity.netcode.gameobjects
Issue tương tự
-
type/automation type/tech-debt
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
-
t/bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
-
ci-failure-cause test-failure
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
-
area:auth FE mvp P3
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
klasolsson81/jobbliggaren#1788 ·