Skip to content

fix: client destroy exception #981

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 30, 2021
Merged

Conversation

LukeStampfli
Copy link
Contributor

A client destroying a spawned network object will now result in a NotServerException. This is done because this is an invalid operation as only the server can destroy/despawn a spawned network object.

Comment on lines +420 to +423
if (NetworkManager != null && NetworkManager.IsListening && NetworkManager.IsServer == false && IsSpawned)
{
throw new NotServerException($"Destroy a spawned {nameof(NetworkObject)} on a non-host client is not valid. Call {nameof(Destroy)} or {nameof(Despawn)} on the server/host instead.");
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this looks safe to me but I'll defer to Noel for the final call.

@LukeStampfli LukeStampfli requested a review from TwoTenPvP July 28, 2021 12:28
Copy link
Collaborator

@NoelStephensUnity NoelStephensUnity left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea...
If you are connected then clients should never do this if the NetworkObject is spawned.
If you are connected but not spawned, then you can continue with the destroy process.
If you are disconnected (and obviously not spawned) then you can continue with the destroy process.

Looks good to me!

@LukeStampfli LukeStampfli merged commit cbe74c2 into develop Jul 30, 2021
@LukeStampfli LukeStampfli deleted the fix/client-destroy-exception branch July 30, 2021 15:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants