I'm making a PvP FPS with Netcode for GameObjects (v2.5.1) & Distributed Authority topology.
So basically, I have a bomb defusal game mode (like in CS2), where players can pick up a bomb.
When picking up the bomb, an ownership request is sent to the one that owns the bomb. If he already owns the bomb, it is then picked up. This ensures the one holding the bomb is also the owner of it.
This normally works fine, but after restarting the match a few times, at some point, the ownership request doesn't work anymore. Also, I can't reproduce it consistently.
On the player, we decide whether to pick up or request ownership
if (bombNetworkObject.IsOwner) {
RequestBombPickUp(bombNetworkObject);
}
else {
RequestBombOwnership(bombNetworkObject);
}
In case we don't have ownership, we request it (targetObject is the bomb)
private void RequestBombOwnership(NetworkObject targetObject) {
if (!targetObject.IsRequestInProgress) {
targetObject.RequestOwnership();
}
}
On the bomb, we have the following code
private bool EventOwnershipRequested(ulong clientrequesting) {
// return false in some specific scenarios
return true;
}
private void EventOwnershipRequestResponse(NetworkObject.OwnershipRequestResponseStatus ownershiprequestresponse) {
if (ownershiprequestresponse == NetworkObject.OwnershipRequestResponseStatus.Approved) {
// Pick up
}
}
Whenever the bug occurs, the client tries to request ownership here
targetObject.RequestOwnership();
with the response "RequestSent"
As the response inside EventOwnershipRequestResponse, I receive "CannotRequest". Sending the request multiple times doesn't help once it's bugged out.
Core issue is that the owner of the bomb never receives the callback EventOwnershipRequested when the bug occurs, otherwise he does.
(Bomb network object in screenshot)
Any idea what it could be?
Thanks a lot!