19 Replies
Hi @MasterOX 水. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
----------------------
To keep track of each player's score in NormalVR, you can use the
RealtimeDictionary
collection. This collection works similarly to a Dictionary<uint, ModelType>
. It is commonly used to represent a model that can have fields that are dynamically added or removed at runtime.
For example, if you need to store the score for N players, you could create a ScoreModel and store instances of it in a RealtimeDictionary using each player's clientID as the key. This way, you can easily manage and update the scores for each player in real-time.
Here is the relevant documentation for more details: RealtimeDictionary (https://normcore.io/documentation/room/collections#non-transactional-collections)
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------<@758040514678489279> kapa.ai is still learning and improving, please let us know how it did by reacting below
here's sample code https://discord.com/channels/393839515074297858/1228303351008202762
and do i sync the dictionary like any other variable?
oh thank you
a dictionary is a collection of models but one thing to keep in mind is that you don't get update events for changes to the contents of the collection
an easy way around that is to add an int property next to the collection which you increment when you change the score of a player if you need updates
ty
also
pretty unrelated but
why do i get this every now and then?
![No description](https://cdn.answeroverflow.com/1234661292745293894/image.png)
you called is unowned self before the model is ready
havent used that method tho
i probably requested client id tho
instantiated prefabs are ready at start, scene views are ready when on model replaced is called or allComponentModelsReplaced event is called
is it because of this?
any model related stuff
you can also use model==null to test
i mean
thats the only thing that could cause it
![No description](https://cdn.answeroverflow.com/1234663594151514216/image.png)
and it does have model == null