Matchmaker Testing - NotServerException

After I changed the min player count to 1. I try to test on the Unity play mode. In the main menu, I click on the Find Match button. It appears to switch scenes for a moment, but it crashes and I get

NotServerException: Destroy a spawned NetworkObject on a non-host client is not valid. Call Destroy or Despawn on the server/host instead.
Unity.Netcode.NetworkObject.OnDestroy () (at ./Library/PackageCache/com.unity.netcode.gameobjects@1.2.0/Runtime/Core/NetworkObject.cs:440)

The Game scene loads when I start as a host.

I’m not sure what is throwing the exception.

Are you able to narrow down where in the code it is trying to destroy the NetworkObject? Is there more to the error than what you pasted above?

Do you have a player prefab or some networked objected in the scene that it could be trying to cleanup and running into the error?

I can’t even figure out which Network Object the code would be trying to destroy. It happens just as the scene changes from Main Menu to Game. I’ve been following the code along the way. I tried deactivating all the network objects in Game just to see if that might change the behavior (CoinSpawner, RespawnHandler, GameHUD, the HealingZones) Didn’t change anything.
I checked again. I got the build and the editor to play together with the build hosting and the editor being a client. The build also crashed when attempting to connect to the server.
This is the console when it runs.

Hi there,
Do you have full stack trace logging enabled in your editor?

That might help trace down the exact object.

Otherwise, if you click on the error, does it highlight any objects in the hierarchy?

I enabled full stack trace logging. Still same result:

It doesn’t highlight anything in the hierarchy.
When I double click it only takes me to the Unity.Netcode namespace:

Oof not a lot of information this error is giving you (shakes fist at Unity).

Looking at your hierarchy, I am seeing two application controllers and networking managers, both of which should be singletons, so that might be your issue there.
Do you have network managers or application controllers present in multiple scenes?

My theory would be it’s trying to clean up extra instances of those classes, and it’s throwing the error when the client tries to delete one of them.

Oof is right… I did finally figure it out. I had missed flipping a boolean. Once I added the “!” it finally worked. Missing it meant the server was in the wrong scene when the connection was made.

1 Like

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms