How to make a player join a room faster?

Is there any kinds of algorithm or strategy that can help player join a room faster?
34 Replies
kapa.ai
kapa.ai4d ago
Hi @Phạm Tuấn Anh. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave: ---------------------- The process of a player joining a room in NormalVR is handled by the Realtime API. The Realtime API automatically connects to a room when your application starts if "Join Room On Start" is enabled. You can also manually join a room by calling the Connect() method along with the name of the room you would like to join. All clients that connect to the same room name will end up connected to the same room server source (https://normcore.io/documentation/realtime). However, the speed at which a player can join a room is largely dependent on the network conditions and the server's response time, which are factors that are mostly out of your control. One thing you can do to ensure a smooth experience is to make sure that any objects that need to persist in the room are flagged to not be destroyed when the last player leaves. This way, when a new player joins, these objects will be restored instantly from the persistent storage source (https://normcore.io/documentation/realtime/common-questions#what-happens-to-my-objects-when-a-room-server-shuts-down). In terms of optimizing the client-side experience, you could consider strategies such as loading assets in the background or using lower-resolution assets initially and then swapping them out for higher-resolution versions once they're loaded. However, these strategies are more related to general game development practices and not specific to NormalVR. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
kapa.ai
kapa.ai4d ago
<@1120683104592465930> kapa.ai is still learning and improving, please let us know how it did by reacting below
Mechabit
Mechabit4d ago
can you give some more detail about what you are doing / need?
Phạm Tuấn Anh
@Mechabit is there any ways for 2 players in seperate rooms can see each others? @Normcore Assistant Is there any ways for 2 players in seperate rooms can see each others?
kapa.ai
kapa.ai4d ago
Let me check the knowledge base for you. One moment! :books: ---------------------- Normcore allows you to connect to multiple room servers simultaneously. This can be used to split large MMORPG spaces into smaller shards or to group traffic to host large events like concerts source (https://normcore.io/documentation/essentials/common-questions#can-i-connect-to-multiple-rooms-at-the-same-time). However, players in separate rooms cannot directly see each other as rooms in Normcore are used to separate groups of players. They’re most commonly used to host a single match for a game or a persistent space for a productivity app. Players who join the same room name will be automatically connected to the same room source (https://normcore.io/documentation/architecture/client). If you want players in separate rooms to interact or see each other, you would need to implement a system where information about players in one room is sent to the other room. This could be done by having a server or a player that is connected to both rooms and relays information between them. However, this would require custom development and is not a built-in feature of Normcore. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
kapa.ai
kapa.ai4d ago
<@1120683104592465930> kapa.ai is still learning and improving, please let us know how it did by reacting below
Phạm Tuấn Anh
is there any ways to pause the synchronization to help reduce the stress/the lag of one room? @Normcore Assistant is there any ways to pause the synchronization to help reduce the stress/the lag of one room?
kapa.ai
kapa.ai3d ago
Let me check the knowledge base for you. One moment! :books: ---------------------- In Normcore, the synchronization of state is handled by the room's datastore. When you make a change to the datastore, it’s automatically replicated to all connected clients. The server sends delta updates for the remainder of the session to conserve bandwidth source (https://normcore.io/documentation/architecture/client#datastore). To reduce the stress or lag in a room, you can adjust the rate at which updates are serialized and sent out by modifying the datastoreFrameDuration property. The default value is 1.0/20.0 which sends updates at 20hz. Setting this value higher results in less frequent updates, which could help reduce the load on the network and the room server source (https://normcore.io/documentation/room/datastore#delta-updates). However, there's no built-in way to pause synchronization entirely. If you want to temporarily stop sending updates, you would need to implement a custom solution. For example, you could add a condition in your code to only make changes to the datastore when certain conditions are met. Remember that reducing the update rate or pausing updates could lead to a less responsive or less synchronized experience for the players. It's important to find a balance between performance and user experience. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
kapa.ai
kapa.ai3d ago
<@1120683104592465930> kapa.ai is still learning and improving, please let us know how it did by reacting below
Phạm Tuấn Anh
@Normcore Assistant what is the meaning of the "Tick" method
kapa.ai
kapa.ai3d ago
Let me check the knowledge base for you. One moment! :books: ---------------------- The Tick() method in Normcore's Room class is used to manually update the state of the room. This method needs to be called every frame. When you call Tick(), any work that Room needs to do for that frame will take place, including: - Checking for connection timeouts - Sending datastore updates to the server - Dispatching any network events that were received over the network since the last Tick() call This method is necessary because Room is not a MonoBehaviour or Unity object that receives events from Unity like Update(). Therefore, you need to manually call Tick() to ensure the room state is updated source (https://normcore.io/documentation/room/room). ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
kapa.ai
kapa.ai3d ago
<@1120683104592465930> kapa.ai is still learning and improving, please let us know how it did by reacting below
Phạm Tuấn Anh
@Normcore Assistant what will happen if I dont call "Tick" per update frame?
kapa.ai
kapa.ai3d ago
Let me check the knowledge base for you. One moment! :books: ---------------------- If you don't call the Tick() method every frame, the Room class in Normcore will not be able to perform its necessary updates for that frame. This includes: - Checking for connection timeouts - Sending datastore updates to the server - Dispatching any network events that were received over the network since the last Tick() call This could lead to a variety of issues, such as the room not being updated with the latest data, network events not being dispatched, and connection timeouts not being detected. This could result in a less responsive or less synchronized experience for the players, and could potentially lead to disconnections or other network-related issues source (https://normcore.io/documentation/room/room). ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
kapa.ai
kapa.ai3d ago
<@1120683104592465930> kapa.ai is still learning and improving, please let us know how it did by reacting below
Phạm Tuấn Anh
@Normcore Assistant is the "Tick" method handled internally or should I manually call it in my code?
kapa.ai
kapa.ai3d ago
Let me check the knowledge base for you. One moment! :books: ---------------------- The Tick() method in Normcore's Room class needs to be called manually in your code. It is not handled internally by the Room class or the Realtime API. This is because Room is not a MonoBehaviour or Unity object that receives events from Unity like Update(). Therefore, you need to manually call Tick() every frame to ensure the room state is updated source (https://normcore.io/documentation/room/room). Here's an example of how you might call Tick() in a Unity Update() method:
void Update() {
realtime.room.Tick();
}
void Update() {
realtime.room.Tick();
}
In this example, realtime is a reference to the Realtime component. This code should be placed in a MonoBehaviour that is active in your scene. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
kapa.ai
kapa.ai3d ago
<@1120683104592465930> kapa.ai is still learning and improving, please let us know how it did by reacting below
Mechabit
Mechabit3d ago
if you're using Realtime in your scene you don't need to interact with Room, that's for custom code situations
Phạm Tuấn Anh
@Normcore Assistant how does that custom room look like in code?
kapa.ai
kapa.ai3d ago
Let me check the knowledge base for you. One moment! :books: ---------------------- A custom room in Normcore is represented by a RealtimeModel. This model represents a collection of states to synchronize. Here's an example of what a typical RealtimeModel might look like:
[RealtimeModel]
public partial class MyModel {
[RealtimeProperty(1, true )] private string _name;

[RealtimeProperty(2, true )] private Color _avatarPrimaryColor;
[RealtimeProperty(3, true )] private Color _avatarAlternateColor;

[RealtimeProperty(4, false)] private Vector3 _movementVelocity;
}
[RealtimeModel]
public partial class MyModel {
[RealtimeProperty(1, true )] private string _name;

[RealtimeProperty(2, true )] private Color _avatarPrimaryColor;
[RealtimeProperty(3, true )] private Color _avatarAlternateColor;

[RealtimeProperty(4, false)] private Vector3 _movementVelocity;
}
In this example, MyModel is a RealtimeModel that contains a name, two colors, and a velocity. Each field is marked with the RealtimeProperty attribute, which tells Normcore to synchronize this field across all clients. The first argument to RealtimeProperty is a unique ID for this property, and the second argument is a boolean that indicates whether this property should be synchronized when a new client connects source (https://normcore.io/documentation/room/realtimemodel). When connecting to a room, you can pass a freshly initialized model that represents the root of your datastore to the Connect() method. Any state changes to this model are replicated to the room model instance on all clients source (https://normcore.io/documentation/room/room#connecting-to-a-room-server). Here's an example:
void ConnectToRoom() {
MyModel myModel = new MyModel();
// Initialize myModel...
realtime.room.Connect("My Room", "My App Key", roomModel: myModel);
}
void ConnectToRoom() {
MyModel myModel = new MyModel();
// Initialize myModel...
realtime.room.Connect("My Room", "My App Key", roomModel: myModel);
}
In this example, realtime is a reference to the Realtime component. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
kapa.ai
kapa.ai3d ago
<@1120683104592465930> kapa.ai is still learning and improving, please let us know how it did by reacting below
Phạm Tuấn Anh
@Normcore Assistant reliable vs unreliable connection, which one is faster?
kapa.ai
kapa.ai3d ago
Let me check the knowledge base for you. One moment! :books: ---------------------- In terms of speed, an unreliable connection can be faster than a reliable one. This is because unreliable updates are not resent if they're dropped in transit. It's expected that another update is following shortly after, so the system doesn't wait for an acknowledgement before sending the next packet. This can make the transmission of data faster, but at the risk of losing some data along the way source (https://normcore.io/documentation/realtime/synchronizing-custom-data#reliable--unreliable). On the other hand, reliable updates are resent if the packet is dropped in transit. This ensures that all data is received, but it can introduce delays as the system waits for acknowledgements and resends dropped packets source (https://normcore.io/documentation/room/realtimemodel#realtimemodel--realtimeproperty-attributes). So, if speed is your primary concern and it's acceptable to lose some data, an unreliable connection might be faster. However, if it's crucial that all data is received, a reliable connection would be the better choice, even though it might be slower. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
kapa.ai
kapa.ai3d ago
<@1120683104592465930> kapa.ai is still learning and improving, please let us know how it did by reacting below
Phạm Tuấn Anh
@Normcore Assistant does normcore limit the number of rooms?
kapa.ai
kapa.ai3d ago
Let me check the knowledge base for you. One moment! :books: ---------------------- Normcore itself can host over a million rooms at the same time. The backend automatically scales based on your usage patterns. It also supports bursting via cloud infrastructure. If Normcore doesn't have enough servers of its own to host your game, it can seamlessly cloud burst into instances on Google Cloud, AWS, and DigitalOcean, ensuring there are always enough rooms source (https://normcore.io/documentation/essentials/common-questions#how-many-rooms-can-normcore-host-concurrently). ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
kapa.ai
kapa.ai3d ago
<@1120683104592465930> kapa.ai is still learning and improving, please let us know how it did by reacting below
Phạm Tuấn Anh
@Normcore Assistant is there any ways to seperate my client model prefab with the realtime view prefab?
kapa.ai
kapa.ai3d ago
Let me check the knowledge base for you. One moment! :books: ---------------------- Yes, you can separate your client model prefab from the RealtimeView prefab. In Normcore, a RealtimeView is used to identify a game object and its RealtimeComponents across multiple clients. When a prefab is instantiated, RealtimeView creates a model for each RealtimeComponent on the prefab and puts it into the datastore source (https://normcore.io/documentation/realtime/realtimeview). You can have a separate prefab for your client model that doesn't include a RealtimeView. However, if you want to synchronize the state of this prefab across multiple clients, you would need to add a RealtimeComponent to it and ensure it's associated with a RealtimeView. Here's an example of how you might do this:
GameObject myObject = Realtime.Instantiate("My Object",
ownedByClient: true);
myObject.GetComponent<MyClientModel>().SetRealtimeView(myRealtimeView);
GameObject myObject = Realtime.Instantiate("My Object",
ownedByClient: true);
myObject.GetComponent<MyClientModel>().SetRealtimeView(myRealtimeView);
In this example, MyClientModel is a script on your client model prefab that has a method SetRealtimeView() for associating the prefab with a RealtimeView. myRealtimeView is a reference to the RealtimeView you want to associate with the prefab. Remember that any changes to the state of the client model prefab won't be synchronized unless they're made through a RealtimeComponent that's associated with a RealtimeView source (https://normcore.io/documentation/realtime/realtimecomponent). ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
kapa.ai
kapa.ai3d ago
<@1120683104592465930> kapa.ai is still learning and improving, please let us know how it did by reacting below
Phạm Tuấn Anh
@Normcore Assistant I want many realtime instances for my client model, this also means that there are many realtime views for my client model, is this possible?
kapa.ai
kapa.ai3d ago
Let me check the knowledge base for you. One moment! :books: ---------------------- Yes, it's possible to have multiple Realtime instances and RealtimeViews for your client model. Each Realtime instance can have its own RealtimeView. When you instantiate a prefab, RealtimeView creates a model for each RealtimeComponent on the prefab and puts it into the datastore. Then, when the prefab is instantiated on other clients, RealtimeView will connect the model in the datastore with its respective RealtimeComponent on the prefab source (https://normcore.io/documentation/realtime/realtimeview). If you plan to have multiple instances in the same scene, you may manually wire up which instance this RealtimeView should use. This is done by setting the Realtime Instance property in the Advanced Settings of the RealtimeView source (https://normcore.io/documentation/realtime/realtimeview#realtime-instance). Here's an example of how you might do this:
// Instantiate the My Object prefab, leave the view unowned.
GameObject myObject1 = Realtime.Instantiate("My Object", ownedByClient: false);
GameObject myObject2 = Realtime.Instantiate("My Object", ownedByClient: false);

// Get the RealtimeView components
RealtimeView realtimeView1 = myObject1.GetComponent<RealtimeView>();
RealtimeView realtimeView2 = myObject2.GetComponent<RealtimeView>();

// Set the Realtime instances
realtimeView1.realtime = myRealtimeInstance1;
realtimeView2.realtime = myRealtimeInstance2;
// Instantiate the My Object prefab, leave the view unowned.
GameObject myObject1 = Realtime.Instantiate("My Object", ownedByClient: false);
GameObject myObject2 = Realtime.Instantiate("My Object", ownedByClient: false);

// Get the RealtimeView components
RealtimeView realtimeView1 = myObject1.GetComponent<RealtimeView>();
RealtimeView realtimeView2 = myObject2.GetComponent<RealtimeView>();

// Set the Realtime instances
realtimeView1.realtime = myRealtimeInstance1;
realtimeView2.realtime = myRealtimeInstance2;
In this example, myRealtimeInstance1 and myRealtimeInstance2 are references to the Realtime instances you want to associate with the RealtimeViews. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
kapa.ai
kapa.ai3d ago
<@1120683104592465930> kapa.ai is still learning and improving, please let us know how it did by reacting below