What is the best way to get the exact time a room is created?
Is there a way to find the room start time?
4 Replies
Hi @mstfmrt07. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
----------------------
I'm sorry, but based on the provided knowledge sources, there doesn't seem to be a direct way to get the exact time a room is created in NormalVR. The
Room
class in Normcore provides a time
property, but this represents the server time on the current frame, not the creation time of the room.
However, you could potentially use a workaround by creating a RealtimeComponent
that records the server time when it is first instantiated. This would give you a rough approximation of when the room was created, as RealtimeComponents
are initialized when the room is connected.
Here's a simple example of how you might do this:
In this example, RoomCreationTime
is a RealtimeComponent
that records the server time in its Start
method. You can then use the GetCreationTime
method to retrieve this time later.
Please note that this is just a workaround and may not give you the exact creation time of the room, especially if there is a delay between when the room is created and when the RealtimeComponent
is initialized.
For more accurate results, you might need to modify the server code or use a different method that isn't covered in the provided knowledge sources.
Sources:
- Room Class (https://normcore.io/documentation/reference/classes/Normal.Realtime.Room)
- RealtimeComponent Class (https://normcore.io/documentation/reference/classes/Normal.Realtime.RealtimeComponent%601)
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------<@208292457979314176> kapa.ai is still learning and improving, please let us know how it did by reacting below
if you run that code during the OnModelReplaced event and isFreshModel == true then only the first player will set the time so late joiners wont override it
Thanks a lot! It worked as expected ❤️