cryptomax
cryptomax9mo ago

Can you get a client id directly from realtimetransform?

Can you get a client id directly from realtimetransform?
26 Replies
kapa.ai
kapa.ai9mo 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.ai9mo ago
<@401986039964631060> kapa.ai is still learning and improving, please let us know how it did by reacting below
cryptomax
cryptomaxOP9mo 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.ai9mo 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.ai9mo ago
<@401986039964631060> kapa.ai is still learning and improving, please let us know how it did by reacting below
Camobiwon
Camobiwon9mo ago
The client ID of the RT owner? Yeah, just model.ownerIDSelf
cryptomax
cryptomaxOP9mo ago
I have a terrible memory and forget what properties i can get to from where 😦
Camobiwon
Camobiwon9mo ago
yeah fair honestly But yeah you can just do rt.ownerIDSelf additionally isOwnedLocallySelf and isOwnedRemotelySelf
cryptomax
cryptomaxOP9mo ago
isn't intelisense supposed to tell you these things if you just rt.?
Camobiwon
Camobiwon9mo ago
Yeah Does it not show for yours?
cryptomax
cryptomaxOP9mo ago
well for me it doesn't
Camobiwon
Camobiwon9mo ago
Check the properties (wrench icon)
Camobiwon
Camobiwon9mo ago
No description
cryptomax
cryptomaxOP9mo 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
Camobiwon9mo ago
I'm using VS2022
cryptomax
cryptomaxOP9mo ago
ah not vs code?
Camobiwon
Camobiwon9mo ago
nah Works better with Unity in my experience
cryptomax
cryptomaxOP9mo ago
I guess that is probably my problem then heh
Mechabit
Mechabit9mo ago
I used to use VScode but it kept breaking with every update and then switched to VS and never looked back. much better support for unity as Camobiwan says.
cryptomax
cryptomaxOP9mo ago
eh i guess I liked it becuase it's lightweight and i'm an artist not a programmer so it's a miracle I'm even coding as it is XD I often code just from the colors the text is hears someone die in the background
Camobiwon
Camobiwon9mo ago
hahahah
cryptomax
cryptomaxOP9mo ago
it's actually true though you would be shocked
Camobiwon
Camobiwon9mo ago
im impressed
Mechabit
Mechabit9mo ago
I started with mono which was pretty lightweight and thought vsCode would be too but it's just not as good as VS
cryptomax
cryptomaxOP9mo ago
well mayeb I will look into it, even just having proper intelisense would be handy
Camobiwon
Camobiwon9mo ago
VS got a reputation for being "bloated" which I don't think is deserved. It's certainly a lot more packed than VSCode but the integrations are just so much better / seamless I didn't have to do anything to get the properties / intellisense to show up, just set the editor to it in your Unity preferences