-
Notifications
You must be signed in to change notification settings - Fork 452
Closed
Labels
priority:highThis issue has high priority and we are focusing to resolve itThis issue has high priority and we are focusing to resolve ittype:bugBug ReportBug Report
Description
Description
DontDestroyWithOwner = true
does not work with SpawnWithObservers = false
Reproduce Steps
Create a new scene.
Setup NetworkManager.
Attach the GameManager script to some object.
Create some sample NetworkObject.
Set the references of GameManager.
Build project.
In editor, press S to start server and spawn sample NetworkObject.
In built app, press C to start client.
In editor, press T to trigger change ownership.
In built app, press C to disconnect.
In editor, spawned NetworkObject is destroyed.
using Unity.Netcode;
using UnityEngine;
public class GameManager : MonoBehaviour {
[SerializeField] private NetworkManager networkManager;
[SerializeField] private NetworkObject testObject;
private NetworkObject testInstance;
private void Update() {
if (Input.GetKeyDown(KeyCode.S)) {
networkManager.StartHost();
testInstance = Instantiate(testObject);
testInstance.SpawnWithObservers = false;
testInstance.DontDestroyWithOwner = true;
testInstance.Spawn();
}
if (Input.GetKeyDown(KeyCode.C)) {
if (networkManager.IsServer || networkManager.IsClient) {
networkManager.Shutdown();
} else {
networkManager.StartClient();
}
}
if (Input.GetKeyDown(KeyCode.T)) {
testInstance.NetworkShow(1);
testInstance.ChangeOwnership(1); //also throws an error client-side
}
}
}
Actual Outcome
Network object is destroyed
Expected Outcome
Network object not destroyed
Environment
- Unity Version: 6000.0.41f1
- Netcode Version: 2.3.2
Metadata
Metadata
Assignees
Labels
priority:highThis issue has high priority and we are focusing to resolve itThis issue has high priority and we are focusing to resolve ittype:bugBug ReportBug Report