RealtimeView get by object id
Is there any way to get the same GameObject on 2 clients by an id?
3 Replies
Hi @Andrei Vaduva. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
----------------------
In NormalVR's Normcore, there isn't a built-in way to get a
RealtimeView
reference at runtime using a UUID or an ID. The RealtimeView
that are in the scene sometimes have a Scene View UUID, but this is used to synchronize the same view when the scene is loaded on multiple clients, not for retrieving RealtimeView
references at runtime.
However, you can introduce this functionality by creating a RealtimeComponent
that assigns a UUID in OnRealtimeModelReplaced()
when getting a fresh model. This will ensure that the component has a unique UUID and that existing models don’t have their UUIDs reassigned by new clients.
Here's an example of how you might do this:
In this example, MyModel
would be a custom model you've created that has a uuidProperty
. When a fresh model is created, a new UUID is generated and assigned to uuidProperty
. If the model isn't fresh (i.e., it's being loaded from the datastore), the UUID is retrieved from uuidProperty
.
Once you've assigned UUIDs to your components, you can create a system to look up RealtimeView
instances by UUID at runtime.
Please note that this is a custom solution and may require additional work to fit your specific needs.
For more information, you can refer to the Normcore Documentation (https://normcore.io/documentation/realtime/common-questions#is-there-a-uuid-that-i-can-use-to-find-a-realtimeview-reference-at-runtime).
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------<@1217086475661738045> kapa.ai is still learning and improving, please let us know how it did by reacting below
I haven't used it, but there's a GUIDManager in #💾sample-code for this purpose:
https://discord.com/channels/393839515074297858/1215145130797830144/1215145130797830144