'RealtimeComponent has been replaced with RealtimeComponent<TModel>. Please upgrade
If i 'm getting this message on a script what features am I missing particularly on the mode?
5 Replies
Hi @cryptomax. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
----------------------
This error message indicates that you're using an older version of Normcore and need to update your script to use the newer
RealtimeComponent<TModel>
class. The main difference is in how the model is handled.
With the newer RealtimeComponent<TModel>
, you get the following benefits:
1. Type-safe access to your model: The TModel
generic parameter ensures you're working with the correct model type.
2. Automatic model property: You get a built-in model
property of the correct type, which you can use to access your synchronized data RealtimeComponent documentation (https://normcore.io/documentation/reference/classes/Normal.Realtime.RealtimeComponent%601).
3. OnRealtimeModelReplaced
method: This method is called when the model is replaced, allowing you to set up event listeners and initialize your component based on the model's state Synchronizing Custom Data (https://normcore.io/documentation/realtime/synchronizing-custom-data#creating-a-realtimecomponent-subclass).
4. Improved performance: The newer version is optimized for better performance.
To upgrade your script, you should:
1. Change your class declaration to inherit from RealtimeComponent<YourModelType>
instead of just RealtimeComponent
.
2. Implement the OnRealtimeModelReplaced
method to set up any necessary event listeners or initialization.
3. Use the model
property to access your synchronized data instead of manually managing a model property.
Here's an example of how your updated script might look:
By upgrading to RealtimeComponent<TModel>
, you'll have a more robust and type-safe way of working with your Normcore components.
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------<@401986039964631060> Kapa.ai is still learning and improving, please let me know how I did by reacting below.
@kapa.ai pre 2.0 normcore models do not support OnRealtimeModelReplaced?
Let me check the knowledge base for you again. One moment! :books:
----------------------
You're correct in your observation. Pre-2.0 Normcore models indeed do not support the
OnRealtimeModelReplaced
method. This method was introduced as part of the improvements in Normcore 2.0.
In Normcore 1.x, the RealtimeComponent
class didn't have the generic type parameter and handled model replacement differently. The OnRealtimeModelReplaced
method is a feature specific to Normcore 2.0 and later versions, which use the RealtimeComponent<TModel>
class Upgrading from Normcore 1 to Normcore 2 (https://normcore.io/documentation/guides/upgrading-from-normcore-1-to-normcore-2).
If you're still using a pre-2.0 version of Normcore, you won't have access to this method. Instead, you would typically handle model changes in a different way, often by implementing a custom setter for your model property.
To take advantage of the OnRealtimeModelReplaced
method and other improvements, it's recommended to upgrade to Normcore 2.0 or later. The upgrade process is designed to be relatively straightforward for most projects and brings significant improvements in transform syncing, voice chat, and overall latency Upgrading from Normcore 1 to Normcore 2 (https://normcore.io/documentation/guides/upgrading-from-normcore-1-to-normcore-2).
If you decide to upgrade, you'll be able to use the more modern RealtimeComponent<TModel>
class with its OnRealtimeModelReplaced
method, which provides a cleaner way to handle model changes and set up event listeners Synchronizing Custom Data (https://normcore.io/documentation/realtime/synchronizing-custom-data#creating-a-realtimecomponent-subclass).
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------<@401986039964631060> Kapa.ai is still learning and improving, please let me know how I did by reacting below.