cryptomax
cryptomax4w ago

OwnerIDSelfDidChange

Does realtimeView Have this event as well or only RealtimeTransform?
5 Replies
kapa.ai
kapa.ai4w ago
Hi @cryptomax. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave: ---------------------- Yes, the RealtimeView class does have the ownerIDSelfDidChange event. This event is dispatched when the ownerIDSelf value changes. Here is the relevant extract from the documentation:
## Events
ownerIDSelfDidChange*event Action<RealtimeView, int> ownerIDSelfDidChange*
Dispatched when the ownerIDSelf value changes.
## Events
ownerIDSelfDidChange*event Action<RealtimeView, int> ownerIDSelfDidChange*
Dispatched when the ownerIDSelf value changes.
You can find more details in the RealtimeView documentation (https://normcore.io/documentation/reference/classes/Normal.Realtime.RealtimeView). Please note that the RealtimeComponent<TModel> and RealtimeModel classes also have the ownerIDSelfDidChange event. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
kapa.ai
kapa.ai4w ago
<@401986039964631060> kapa.ai is still learning and improving, please let us know how it did by reacting below
cryptomax
cryptomax4w ago
@Normcore Assistant does the player who requests ownership of the view still receive the ownerIDchange event?
kapa.ai
kapa.ai4w ago
Let me check the knowledge base for you. One moment! :books: ---------------------- Yes, the player who requests ownership of the view will still receive the ownerIDSelfDidChange event. This event is dispatched whenever the ownerIDSelf value changes, regardless of who initiated the change. When a player requests ownership using RequestOwnership(), and the request is successful, the ownerIDSelf value will change to the client ID of the requesting player. This change will trigger the ownerIDSelfDidChange event. Here is a code example of requesting ownership:
// Get the RealtimeView component
RealtimeView myObjectView = myObject.GetComponent<RealtimeView>();

// Mark the RealtimeView owned by the local client
myObjectView.RequestOwnership();
// Get the RealtimeView component
RealtimeView myObjectView = myObject.GetComponent<RealtimeView>();

// Mark the RealtimeView owned by the local client
myObjectView.RequestOwnership();
And here is how you might listen for the ownerIDSelfDidChange event:
myObjectView.ownerIDSelfDidChange += OnOwnerIDSelfDidChange;

void OnOwnerIDSelfDidChange(RealtimeView view, int newOwnerID) {
// Handle the event here
}
myObjectView.ownerIDSelfDidChange += OnOwnerIDSelfDidChange;

void OnOwnerIDSelfDidChange(RealtimeView view, int newOwnerID) {
// Handle the event here
}
Remember that the RequestOwnership() and ClearOwnership() methods take effect immediately, but if the server blocks the request—say, because preventOwnershipTakeover 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. You can find more details in the RealtimeView documentation (https://normcore.io/documentation/reference/classes/Normal.Realtime.RealtimeView). ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
kapa.ai
kapa.ai4w ago
<@401986039964631060> kapa.ai is still learning and improving, please let us know how it did by reacting below