Ryan Green
Ryan Green2mo ago

how do i fetch items in a realtimeset?

I have RealtimeSet of PlayerModel objects, how do I fetch an item from this set?
2 Replies
kapa.ai
kapa.ai2mo ago
Hi @Ryan Green. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave: ---------------------- To fetch an item from a RealtimeSet in NormalVR, you can use the GetEnumerator method. This method returns an enumerator that iterates through the RealtimeSet. Here's a simple example of how you might use it:
IEnumerator<PlayerModel> enumerator = yourRealtimeSet.GetEnumerator();
while (enumerator.MoveNext())
{
PlayerModel playerModel = enumerator.Current;
// Do something with playerModel
}
IEnumerator<PlayerModel> enumerator = yourRealtimeSet.GetEnumerator();
while (enumerator.MoveNext())
{
PlayerModel playerModel = enumerator.Current;
// Do something with playerModel
}
Please note that RealtimeSet is an unordered collection of models, so the order in which you retrieve the items is not guaranteed. If you need to find a specific item, you'll need to iterate over the entire set and check each item until you find the one you're looking for. For more information, you can refer to the RealtimeSet documentation (https://normcore.io/documentation/reference/classes/Normal.Realtime.Serialization.RealtimeSet%601). ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
kapa.ai
kapa.ai2mo ago
<@337874773742845953> kapa.ai is still learning and improving, please let us know how it did by reacting below