com.unity.netcode.gameobjects icon indicating copy to clipboard operation
com.unity.netcode.gameobjects copied to clipboard

OnGainedOwnership and OnLostOwnership callback functions should be used more generically.

Open junyeop opened this issue 3 years ago • 2 comments

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

The ownership callback function is only called when calling the ChangeOwnership and RemoveOwnership functions.

However, the ownership callback function should be called in every case an object gains or loses ownership.

For example, when creating an object with the SpawnWithOwnership function, the ownership callback function is not called.

So you need to write a separate code to check the IsOwner status in the NetworkStart function.

Also, is there any reason the OnGainedOwnership and OnLostOwnership callback functions are only called on the client?

I think it could be used more generally if you call it from both server and client.

Describe the solution you'd like OnGainedOwnership and OnLostOwnership callback functions should be used more generically. Ex. SpawnWithOwnership

Describe alternatives you've considered The ownership callback function should be called in every case an object gains or loses ownership.

junyeop avatar Jul 31 '21 09:07 junyeop

I've just had the same surprise as you, expecting it would've worked like you're describing but it isn't.

WhippetsAintDogs avatar Jan 13 '22 21:01 WhippetsAintDogs

Ran into this as well. If a method is called OnGainedOwnership it should be called no matter how ownership is gained. i.e. when SpawnWithOwnership is preformed.

No opinion on needing it to be called on the server as well, although that does seem logical at first glance

ChrisJD-VMC avatar May 29 '22 20:05 ChrisJD-VMC