com.unity.netcode.gameobjects
com.unity.netcode.gameobjects copied to clipboard
OnGainedOwnership and OnLostOwnership callback functions should be used more generically.
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.
I've just had the same surprise as you, expecting it would've worked like you're describing but it isn't.
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