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?
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
and it does have model == null
dunno, you'll have to debug it to find out
i added it in startgame as well
couldve been bcuz of that actually
you can disable scripts until it stops happening and then add a code break where you think it might happen then you can view the values of each property in your IDE
oke, but it does happen right before i activate the start game method, and now that i think about it, most of the time i click on start game as fast as possible. so its most likely because of that