Small replication question

I’m setting up a clothing system for our characters in our game. I’ve got things set up in a way so that the character holds a few variables which define what the hat, chest, legs, feet and hand clothing items are. These variables are replicated. Now first I used a skeletal mesh reference which was set to repnotify, whenever the mesh changes other clients would then change their mesh accordingly. Which worked. But I think I found a more efficient way, by using assetID variables. Now I changed the mesh variables to assetID variables which are also repnotify. When the assetID of the head changes for example, the connected clients get the updated assetID and load the asset and then change their mesh accordinly. This also works perfectly. Now, my question is, is this better and more network efficient than using replicated references? As far as I can guess assetID are just ID’s (number) right?

Also, one other question that has been on my mind for a while now. Does Unreal engine replicate variables only when they are changed, or are they updated over network every network tick? And does repnotify has a difference replication method / frequency than normal replication or is the only difference that there is a notification function that is called on change?

Hi,

I cannot really answer your first question, but I would also assume that an integer is more efficient to replicate than an object reference.

If I remember correctly, replicated variables only update on the network when their values were changed, but there is a slight overhead of checking if this condition was met. I believe variables marked RepNotify are the most efficient, as they call a function only when their values were changed.

Have a look here, maybe you find something useful:
https://docs.unrealengine.com/latest/INT/Resources/ContentExamples/Networking/index.html

It seems like I have a problem with the assetID replication. Everything worked fine until I restarted the project. Now when I try to replicate an assetId variable it crashes the editor. :frowning: Anyone know why?

EDIT: Ok I found out what is causing the crash. Basically it’s an assetID array which is set to repnotify. Now inside the repnotify function is called a function that loads all the assets from the assetID array using a Do N node. The problem is that the array isn’t fully replicated yet when the custom function has already begun trying to load the assets. How could I delay the repnotify until the entire array is fully replicated?

NVM, I was wrong, that’s not the reason of the crash. I unplugged the load asset function and only kept the assetID array replicating and it still causes the crash. So does this mean that assetID array can’t be replicated?

EDIT 2: Okay I fixed it (I think).

This is how I did the replication first. Which causes the crash.

Then I tried this:

And it works, no more crashes. Basically instead of completely refreshing the array all at once I refresh item per item. Not sure why the former causes a crash, too much replication to handle at once perhaps? I’m still kind of doubtful of this approach though? Is this efficient enough / safe?