isOwnedLocallySelf and isOwnedRemotelySelf seem to be false?
I have a MonoBehaviour hook itself up to Realtime's didConnectToRoom event, then when that event is fired it uses Realtime.Instantiate to create a remote character
The issue is, this remote rig has a realtime component, and for some reason whenever this realtime component accesses isOwnedLocallySelf or isOwnedRemotelySelf they always return false? In the editor if I inspect the remote rig instantiated by the local client, it does say that the owner is the local client, but for some reason accessing those properties says otherwise
9 Replies
Hi @Ethan Barron. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
----------------------
Based on the information in the knowledge sources, there are a few important details to consider regarding ownership properties like
Accessing ownership properties (such as
Your instantiation code is correct and should assign ownership to the local client, as you are using
If you need to check ownership immediately after instantiation, ensure you do so after the
The inspector may show the correct owner because it updates after the model is initialized, but your code might be running before this initialization is complete. Recommendation:
Move any logic that checks
The most likely reason
isOwnedLocallySelf
and isOwnedRemotelySelf
on a RealtimeComponent
:
1. Timing of Property Access:Accessing ownership properties (such as
isOwnedLocallySelf
) before the component is fully initialized can yield incorrect results. For prefab-instantiated objects, these properties are reliably set after Start()
is called. If you access them immediately after instantiation or in Awake()
, they may not yet reflect the correct ownership state. The documentation specifically notes that accessing properties like realtimeView
, realtime
, or room
before Start()
is unreliable for prefab views, and for scene views, you must wait until the room is connected and models are initialized [RealtimeView Reference].
2. Correct Instantiation:Your instantiation code is correct and should assign ownership to the local client, as you are using
ownedByClient = true
in Realtime.Instantiate()
. This should result in the root RealtimeView
being owned by the local client, and thus isOwnedLocallySelf
should be true
on components attached to that view [Ownership + Lifetime Flags].
3. When to Check Ownership:If you need to check ownership immediately after instantiation, ensure you do so after the
Start()
method has run on your component. For scene objects, you should wait until realtime.connected == true
or the didConnectToRoom
event has fired [Common Questions].
4. Inspector vs. Code:The inspector may show the correct owner because it updates after the model is initialized, but your code might be running before this initialization is complete. Recommendation:
Move any logic that checks
isOwnedLocallySelf
or isOwnedRemotelySelf
into the Start()
method or, even better, into the OnRealtimeModelReplaced()
method of your RealtimeComponent<TModel>
. This ensures the model and ownership state are fully initialized before you access them.
Summary:The most likely reason
isOwnedLocallySelf
and isOwnedRemotelySelf
are both false
is that you are checking them before the ownership state is fully initialized. Wait until Start()
or OnRealtimeModelReplaced()
to access these properties for reliable results [RealtimeComponent<TModel> Reference].
If you continue to see this issue even after moving your logic, double-check that your prefab is set up correctly and that you are not accidentally using Unity's Instantiate()
instead of Realtime.Instantiate()
[Common Questions].
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------<@540897871545892884> Kapa.ai is still learning and improving, please let me know how I did by reacting below.
@Normcore Assistant
1. I am doing it in OnRealtimeModelReplaced but I've also tried constantly logging isOwnedLocallySelf or isOwnedRemotelySelf in LateUpdate, and both always return false
3. I think I'm already doing that right? didConnectToRoom is called after the connection is done and datastores are synced, so I should be ready to access them then no?
Let me check the knowledge base for you again. One moment! :books:
----------------------
You're correct that
If
didConnectToRoom
is only fired after the connection is established and datastores are synced, so in theory, you should be able to instantiate and interact with ownership properties at that point. Also, checking isOwnedLocallySelf
or isOwnedRemotelySelf
in OnRealtimeModelReplaced
or even in LateUpdate
should reflect the correct ownership state, assuming the prefab and instantiation are set up properly.
However, according to the knowledge sources, if both isOwnedLocallySelf
and isOwnedRemotelySelf
are always returning false
, even after initialization, this suggests one of the following:
- The object may not actually be owned by any client (i.e., it is unowned). In this case, both properties would be false
, and isUnownedSelf
would be true
[RealtimeComponent<TModel> Reference].
- There could be an issue with the prefab setup, such as the RealtimeView
or RealtimeComponent
not being properly registered or initialized. The documentation notes that if the prefab is corrupt or not set up correctly, the model may not be created or assigned, leading to unexpected property values [RealtimeComponents Common Questions].
- If you are using Unity's Instantiate()
instead of Realtime.Instantiate()
, the components will not be networked and ownership will not be set, but your code sample shows you are using Realtime.Instantiate()
.
What you can check:
- In the inspector, confirm that the ownerIDSelf
property on the RealtimeView
and your RealtimeComponent
matches your local client ID.
- Log the value of isUnownedSelf
as well. If it is true
, the object is not owned by anyone.
- Ensure your prefab has a RealtimeView
at the root and that all RealtimeComponent
s are properly listed in the inspector on that view.
- Make sure you are not accidentally clearing ownership elsewhere in your code.
If all of these checks look correct and the issue persists, the knowledge sources do not provide further troubleshooting steps for this specific scenario. It may be a rare edge case or a bug. In that case, reaching out to the Normcore community or support may be necessary.
Summary:If
isOwnedLocallySelf
and isOwnedRemotelySelf
are always false
, and you are using Realtime.Instantiate()
after didConnectToRoom
, double-check the prefab setup and log isUnownedSelf
. If the object is unowned, ownership assignment may not be happening as expected. The knowledge sources do not provide a definitive answer beyond these checks [RealtimeComponent<TModel> Reference][RealtimeComponents Common Questions].
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------<@540897871545892884> Kapa.ai is still learning and improving, please let me know how I did by reacting below.
@Normcore Assistant Seems you were right with your isUnownedSelf idea, how should I go about actually owning it then? I thought I already did this when I instantiated it
Let me check the knowledge base for you again. One moment! :books:
----------------------
If your instantiated object is unowned (
Make sure you are passing
If for some reason ownership is not set during instantiation, you can explicitly request ownership on the
Ensure your prefab is set up correctly with a
isUnownedSelf == true
), it means ownership was not assigned as expected during instantiation. Normally, setting ownedByClient: true
in Realtime.Instantiate()
should make the local client the owner of the root RealtimeView
and, by extension, its child components (Ownership + Lifetime Flags).
To ensure ownership:
1. Double-check your instantiation code:Make sure you are passing
ownedByClient: true
in the InstantiateOptions
when calling Realtime.Instantiate()
. Your earlier code looks correct, but confirm that the prefab's root has a RealtimeView
and that there are no typos or logic errors.
2. Manually request ownership after instantiation:If for some reason ownership is not set during instantiation, you can explicitly request ownership on the
RealtimeView
after instantiating the object:
This is functionally equivalent to setting ownedByClient: true
during instantiation, but it can help in cases where the initial assignment fails for some reason (Requesting ownership of a RealtimeView).
3. Check for prefab setup issues:Ensure your prefab is set up correctly with a
RealtimeView
at the root and that all RealtimeComponent
s are properly registered under it. If the prefab is missing a RealtimeView
, ownership cannot be assigned.
If you follow these steps and the object is still unowned, there may be an issue with the prefab or the instantiation process. The knowledge sources do not provide further troubleshooting steps beyond these recommendations. If the problem persists, consider reaching out to the Normcore community for additional support.
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------<@540897871545892884> Kapa.ai is still learning and improving, please let me know how I did by reacting below.
Solution 2 worked, thanks