If two players request ownership at the same moment
Are there circumstances where it looks momentarily like you could own the item locally but then your ownership is rejected by the server?
RequestOwnership() and methods take effect immediately. However, if the server blocks the requestβsay, because is true or because the view's parent is owned by another clientβthen ownership and all changes that required ownership will be rolled back. RequestOwnership() is called. Normcore will assume the call is going to succeed, and will roll back any state changes automatically if the call is rejected by the server. A RequestOwnership() call is only rejected if the RealtimeView or a parent RealtimeView is owned by a different client.ClearOwnership()preventOwnershipTakeoverisOwnedLocallyInHierarchyisOwnedLocallyInHierarchyisOwnedLocallyInHierarchyRealtimeViewisOwnedLocallySelfisOwnedLocallySelf// Mark the RealtimeView owned by the local client
myObjectView.RequestOwnership();
// Clear ownership of the RealtimeView
myObjectView.ClearOwnership(); IEnumerator CheckOwnershipNextFrame(RealtimeView realtimeView)
{
// Wait for the next frame
yield return null;
// Check if the object is still owned locally
if (realtimeView.isOwnedLocallyInHierarchy)
{
// The object is still owned locally
Debug.Log("Ownership confirmed");
}
else
{
// The object is not owned locally
Debug.Log("Ownership rejected");
}
}
// Usage
StartCoroutine(CheckOwnershipNextFrame(myRealtimeView));