I am having issues with PreventOwnershipTakeover from being respected.
I am having issues with PreventOwnershipTakeover from being respected. I have an object called HostCore which is intended to be used as a way to have HostActions be run once, and when one person who is the host "leaves" then a new host is determined. Currently the PreventOwnershipTakeover value is true (using realtime view, but I have tried this on the custom model as well) but when any other user RequestsOwnership, it is granted. I am wondering if this is moreso due to how my scene is set up. Either way , solving this would be ideal or some best practices around "Host" flow...
3 Replies
Hi @ixikos. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
----------------------
It sounds like you are correctly setting the
preventOwnershipTakeover
flag to true
on your HostCore object’s RealtimeView (and/or custom model), but other users are still able to take ownership when they call RequestOwnership()
. According to the Normcore documentation, when preventOwnershipTakeover
is set to true
, the server should deny any client’s attempt to change the ownership of an object unless it is currently unowned. This applies both to RealtimeView and to custom models with a meta-model enabled Prevent ownership takeover of a RealtimeView.
A few things to check and best practices:
1. Hierarchy Ownership: If a parent RealtimeView is unowned, or if ownership is not set up as you expect in the hierarchy, the server may allow ownership changes on children. Ownership settings on parent views/models are enforced on all children Ownership + Lifetime Flags. Make sure that the parent RealtimeView (if any) is also owned and has preventOwnershipTakeover
set if you want to enforce this throughout the hierarchy.
2. Prefab vs. Scene Object: If you are instantiating HostCore as a prefab, ensure you are setting the preventOwnershipTakeover
flag at instantiation time using the InstantiateOptions
struct, or set it on the model after instantiation but before any ownership requests are made RealtimeView Advanced Settings.
3. Meta-Model for Custom Models: If you are using a custom RealtimeModel, you must compile it with createMetaModel: true
for ownership and the preventOwnershipTakeover
flag to work Requesting ownership of any RealtimeComponent or RealtimeModel.
4. Ownership Clearing: The only time another client should be able to take ownership is if the object is unowned (ownerID == -1). If ownership is being cleared (perhaps automatically or by code), then another client can claim it even with preventOwnershipTakeover
set.
5. Debugging: At runtime, you can use the RealtimeView inspector to check the current owner and the state of preventOwnershipTakeover
. This can help verify that the flag is set as expected RealtimeView Advanced Settings.
Best Practices for Host Flow:
- The host should be the owner of the HostCore object.
- Set preventOwnershipTakeover
to true
so only the current owner (host) or the server can clear ownership.
- When the host leaves, the server should clear ownership, making the object unowned. At this point, a new host can claim ownership.
- Avoid programmatically clearing ownership unless you intend to allow a new host to be selected.
If you have verified all of the above and the issue persists, it may be related to how/when the flag is set or a specific quirk in your scene hierarchy. The knowledge sources do not mention any known bugs with this flag, so a careful review of your object instantiation and ownership logic is recommended.
If you need to enforce stricter host logic, you may also consider using server-side plugins for more advanced control, but this is not required for most use cases.
If you need more specific troubleshooting, please provide details about how and when you set the flag and instantiate HostCore.
---
References:
- Prevent ownership takeover of a RealtimeView
- Ownership + Lifetime Flags
- Requesting ownership of any RealtimeComponent or RealtimeModel
- RealtimeView Advanced Settings
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------<@346532823143809046> Kapa.ai is still learning and improving, please let me know how I did by reacting below.
all the above is true, so I am wondering if this is how my scene and realtime instantiate. Basically inside a helper component, I have a series of checks to make sure realtime is available, and once it is I enable RealtimeView and HostCore components