HaRrY
HaRrY
NNormal
Created by HaRrY on 5/16/2024 in #🤝ask-a-question
How to clear RealtimeSet or RealtimeArray
I run matches on loop. And before I start a new match I have to clear the previous scores etc that are stored in RealtimeArray. Lets say there are 10 matches, each match has its score, now this score used to be stored in RealtimeArray, now I am using RealtimeSet so that I can clear it. So I cannot clear RealtimeArray and the only way I can clear RealtimeSet is by using this while (model.advents.Any()) { model.advents.Remove(model.advents.Last()); } And even though I am doing the above only on 1 client sometimes I feel like its not consistent, I dont know even if I should do this or is there a better way to do this. Or how would you fellow normcorians have done it?
8 replies
NNormal
Created by HaRrY on 4/15/2024 in #🤝ask-a-question
Trying to update a value reliably
I have a realtime property for example fillpercentage property. Now every client can update that property (increment/decrement) but the issue is that there is a slight chance that they might override each other values instead of adding on top of eachother. For example the default value is 0 -> then client 1 did currentVal + 10 and client 2 also did currentVal + 10 but if they both did it on the same time then currentFillPercentage will be 10 instead of 20 right? I have following ways to solve it but each solution have some pros and cons. Please let me know if there is a solution that is robust in everyway. I am not using Normcore private or headless builds and likely wont use it anytime soon. Using RealtimeDictionary or RealtimeArrays: Pros: We can record the last few added values. For example client 1 can add 5, client 2 can add 10 and client 3 can add 15 and all 3 events would be recieved on all clients and only 1 client (e.g. master client) can process them 1 by 1. Cons:. It might take sometime to sync that and its not a good experience also if the master client took off his headset for like few seconds then the game would stop updating the fillPercentage values. You might say to apply the local change first but then it opens issues of having outdated/false values if you have such a bad ping Here is what I would likely want: I want it to be so reliable that I dont miss any users value changes, I also want it to be sequential like these delta updates changes should happen sequentially, I would like it to be instant if possible and last but not least I want to detect reliably that who was the first client that made the fillPercentage = 0 so that I can add that users score etc. I can use StringKeyDictionary for the scoring part but reliably calculating all the fillPercentages delta changes and making sure its not relying on only 1 client because we are not using headless build is a challenge.
30 replies
NNormal
Created by HaRrY on 3/26/2024 in #🤝ask-a-question
How to clear RealtimeArray?
I am using RealtimeArrays to store RealtimeModels for scoring like kills/deaths etc. There is a use-case where I need to reset the scores and everything. How do I clear/remove all elements of RealtimeArray to start from scratch?
6 replies