fgamez1020
fgamez10205w ago

RealTime Model

How to create a real time model that handles an int property?
2 Replies
kapa.ai
kapa.ai5w ago
Hi @fgamez1020. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave: ---------------------- Creating a RealtimeModel in NormalVR that handles an integer property involves defining a class with the [RealtimeModel] attribute and then defining the integer property with the [RealtimeProperty] attribute. Here's a simple example:
[RealtimeModel]
public partial class MyModel {
[RealtimeProperty(1, true)] private int _myIntProperty;
}
[RealtimeModel]
public partial class MyModel {
[RealtimeProperty(1, true)] private int _myIntProperty;
}
In this example, MyModel is the name of the model, and _myIntProperty is the integer property we want to synchronize. The 1 in the RealtimeProperty attribute is the property ID, which should be unique within this model. The true indicates that this property should be synced reliably. After defining the model, you need to compile it in the Unity editor. Highlight the model file in your project, and the inspector should display the model inspector. Click the "Compile Model" button to compile the model. For more details, you can refer to the Creating a custom realtime component (https://normcore.io/documentation/realtime/synchronizing-custom-data#creating-a-custom-realtime-component) and RealtimeModel / RealtimeProperty attributes (https://normcore.io/documentation/room/realtimemodel#realtimemodel--realtimeproperty-attributes) sections in the Normcore documentation. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
kapa.ai
kapa.ai5w ago
<@1053407831916822528> Kapa.ai is still learning and improving, please let me know how I did by reacting below.