cryptomax
cryptomax5mo ago

Can you get a client id directly from realtimetransform?

Can you get a client id directly from realtimetransform?
26 Replies
kapa.ai
kapa.ai5mo 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: ---------------------- No, you cannot directly get a client ID from RealtimeTransform. However, you can get the client ID from the RealtimeComponent or RealtimeView that owns the RealtimeTransform. You can use the ownerIDSelf property of the RealtimeComponent or RealtimeView to get the client ID of the component owner. Here's an example of how you might do this:
// Get the RealtimeTransform component
RealtimeTransform realtimeTransform = myObject.GetComponent<RealtimeTransform>();

// Get the RealtimeView that owns this component
RealtimeView realtimeView = realtimeTransform.realtimeView;

// Get the client ID of the component owner
int ownerID = realtimeView.ownerIDSelf;
// Get the RealtimeTransform component
RealtimeTransform realtimeTransform = myObject.GetComponent<RealtimeTransform>();

// Get the RealtimeView that owns this component
RealtimeView realtimeView = realtimeTransform.realtimeView;

// Get the client ID of the component owner
int ownerID = realtimeView.ownerIDSelf;
Please note that accessing these properties before Start is unreliable. For more information, you can refer to the RealtimeComponent (https://normcore.io/documentation/reference/classes/Normal.Realtime.RealtimeComponent%601) and RealtimeView (https://normcore.io/documentation/reference/classes/Normal.Realtime.RealtimeView) documentation. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
kapa.ai
kapa.ai5mo ago
<@401986039964631060> kapa.ai is still learning and improving, please let us know how it did by reacting below
cryptomax
cryptomax5mo ago
@Normcore Assistant the view is not usually owned so that would not tell us the client id of the realtime transform owner though
kapa.ai
kapa.ai5mo ago
Let me check the knowledge base for you. One moment! :books: ---------------------- You're correct. The RealtimeTransform component and the RealtimeView can have different owners. If you want to get the client ID of the owner of the RealtimeTransform, you should use the ownerIDSelf property of the RealtimeTransform itself, not the RealtimeView. Here's how you can do it:
// Get the RealtimeTransform component
RealtimeTransform realtimeTransform = myObject.GetComponent<RealtimeTransform>();

// Get the client ID of the RealtimeTransform owner
int ownerID = realtimeTransform.ownerIDSelf;
// Get the RealtimeTransform component
RealtimeTransform realtimeTransform = myObject.GetComponent<RealtimeTransform>();

// Get the client ID of the RealtimeTransform owner
int ownerID = realtimeTransform.ownerIDSelf;
This will give you the client ID of the current owner of the RealtimeTransform. If the RealtimeTransform is not owned by any client, ownerIDSelf will return -1. For more information, you can refer to the RealtimeComponent (https://normcore.io/documentation/reference/classes/Normal.Realtime.RealtimeComponent%601) documentation. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
kapa.ai
kapa.ai5mo ago
<@401986039964631060> kapa.ai is still learning and improving, please let us know how it did by reacting below
Camobiwon
Camobiwon5mo ago
The client ID of the RT owner? Yeah, just model.ownerIDSelf
cryptomax
cryptomax5mo ago
I have a terrible memory and forget what properties i can get to from where 😦
Camobiwon
Camobiwon5mo ago
yeah fair honestly But yeah you can just do rt.ownerIDSelf additionally isOwnedLocallySelf and isOwnedRemotelySelf
cryptomax
cryptomax5mo ago
isn't intelisense supposed to tell you these things if you just rt.?
Camobiwon
Camobiwon5mo ago
Yeah Does it not show for yours?
cryptomax
cryptomax5mo ago
well for me it doesn't
Camobiwon
Camobiwon5mo ago
Check the properties (wrench icon)
Camobiwon
Camobiwon5mo ago
No description
cryptomax
cryptomax5mo ago
I can manually trigger it using crtl space but even then it just shows abc items instead of wrenches, and I dont have the little icones you do there
Camobiwon
Camobiwon5mo ago
I'm using VS2022