Checking realtimeTransform.isOwnedLocallySelf
Is checking this identical to checking any local bool in a script or does it have to fetch that property from the server?
7 Replies
Hi @cryptomax. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
----------------------
The
isOwnedLocallySelf
property of a RealtimeModel
in NormalVR is a boolean that indicates whether the model is owned by the local client. It's similar to checking a local boolean in a script, but it's specifically related to the ownership status of the model in the context of a multiplayer environment.
This property does not need to fetch the information from the server each time it's checked. It's updated locally based on the ownership status of the model, which is determined by the server when ownership is requested or transferred.
In a similar way, the isOwnedLocallyInHierarchy
property checks if the model or any of its parents are owned locally.
Remember, in order to move an object with a RealtimeTransform
component, your client needs to be the owner of the RealtimeTransform
component. You can request ownership of a RealtimeTransform
component by calling RequestOwnership()
.
Here are the relevant sources for more information:
- RealtimeModel Properties (https://normcore.io/documentation/reference/classes/Normal.Realtime.RealtimeModel)
- RealtimeTransform How it works (https://normcore.io/documentation/realtime/realtimetransform#how-it-works)
- Networked Physics (https://normcore.io/documentation/realtime/networked-physics#ownership--physics)
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------<@401986039964631060> kapa.ai is still learning and improving, please let us know how it did by reacting below
isOwnedLocallySelf
/ isOwnedRemotelySelf
specifically is kind of expensive at the moment because it has to do an external plugin call. Local bool would be much faster, I'd recommend looking at Liam's RealtimeTransformOptimizer since it avoids this problem by using ownerIDSelf
instead which is way way faster. Fortunately this is already made aware to Max and it's on their plans to fixSo that means this bot response isn’t actually correct here?
It doesn't know about the lower level internals
Interesting, I am using the optimizer I’ll have to look at then if I could tweak it to just update a bool when needed and then simply check that actual local bool in my update instead of isownedlocally
yeah thanks nice idea! I can just make it public and use it instead of doing the isOwnedlocal call!
and thanks @liamc for providing your script
No worries!