The error occurs if you try to send an RPC before the Strix Replicator component’s initialization finishes and the Actor’s synchronization functions are ready. (This error may be displayed as “Can't use the RPC when not instance id is not assigned yet.” in some Strix Unity SDK versions.)
After spawning an Actor with StrixReplicator attached, it takes several frames (or more under higher network latency) before the replicator communicates with the server to finish its initialization. You can’t send an RPC during the initialization.
You can avoid the error by the following techniques:
If you need to send an RPC for the purpose of Actor’s initialization, for example, from the Begin Play
event, you can use Strix Replicator’s On Sync Begin
event instead. On Sync Begin
event is executed when the initialization of the Strix Replicator completes and the synchronization operations become ready. You can avoid the error by moving the avatar initialization codes (or parts of the initialization that uses RPC) from Begin Play
to On Sync Begin
. (Please note, however, that you usually register RPC functions in On Sync Begin
. Initialization codes moved from Begin Play
should be executed after registering RPC functions.)
If you are sending RPC from Tick
or other repeating event handler, and the event is executed during the initialization of Strix Replicator, you can skip the process until the initialization of the replicator completes. You can use Strix Replicator’s GetIsReplicating() member function to determine whether the Strix Replicator’s synchronization/replication has started, and you can skip sending the RPC if it has not started (i.e., the initialization has not completed) to avoid the error.