Skip to content

Changing ownership of NetworkObject: Change OwnerClientId before calling OnGainedOwnership #1075

Closed
@SubtleSanity

Description

@SubtleSanity

Is your feature request related to a problem? Please describe.

In the HandleChangeOwner() method of InternalMessageHandler.cs
When the server gives ownership of an existing network object to a client, the client calls the OnGainedOwnership method on any child NetworkBehaviours, then it changes the OwnerClientId variable on the NetworkObject.

Note that it doesn't change the OwnerClientId variable until after it calls the methods telling us that the variable has changed. This means that when you implement the OnGainedOwnership methods on a NetworkBehaviour the client doesn't think it owns that NetworkObject even tho the entire purpose of the method is to tell us that it does.

This seems counter-intuitive and means that you can't do anything that requires ownership (such as calling a ServerRPC) in a method who's purpose is to tell you that you have ownership .

Describe the solution you'd like
The OwnerClientId variable should be changed on the NetworkObject before calling the OnGainedOwnership and OnLostOwnership methods on its NetworkBehaviours

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions