Description
Instantiating a NetworkObject prefab and passing in a NetworkObject parent causes the client to error with NotServerException.
Reproduce Steps
- Start server
- Connect with client
- Instantiate a NetworkObject prefab on server. Store as
someOtherNetworkObject. (This also works with an in-scene NetworkObject).
- Instantiate a NetworkObject prefab on server with
Instantiate(prefab, Vector3.zero, Quaternion.identity, someOtherNetworkObject).
Actual Outcome
Client produces error of NotServerException: Only the server can reparent NetworkObjects and NetworkObject is not reparented.
Expected Outcome
Object is reparented on client with no error.
Environment
- OS: Windows
- Unity Version: 2021.3.2f1
- Netcode Version: 1.0.0-pre.9
Additional Context
As a workaround, instantiating the GameObject, spawning, then reparenting works. Ideally though this would work automatically, or at least give a message that spawned NetworkObjects should have a null parent.
Description
Instantiating a NetworkObject prefab and passing in a NetworkObject parent causes the client to error with
NotServerException.Reproduce Steps
someOtherNetworkObject. (This also works with an in-scene NetworkObject).Instantiate(prefab, Vector3.zero, Quaternion.identity, someOtherNetworkObject).Actual Outcome
Client produces error of
NotServerException: Only the server can reparent NetworkObjectsand NetworkObject is not reparented.Expected Outcome
Object is reparented on client with no error.
Environment
Additional Context
As a workaround, instantiating the GameObject, spawning, then reparenting works. Ideally though this would work automatically, or at least give a message that spawned NetworkObjects should have a null parent.