Client NetworkObjects experience Awake, Start, OnEnable, and TriggerEnter, CollisionEnter at world 0,0,0 upon instantiation
@NoelStephensUnity is already working on this.
Since Jul 17, 2025.
Assessment
This issue has not been assessed yet.
Description
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
- 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:import type:bug
Difficulty 4/5 3-5 days Newbie friendliness 68/100
-
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
-
type/automation type/tech-debt
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
t/bug
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
-
ci-failure-cause test-failure
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
-
area:auth FE mvp P3
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
klasolsson81/jobbliggaren#1788 ·