I’ve been fiddling with skeletal mesh replication for a week now and, although I have searched everywhere, I cannot seem to find a way to make it work. If anyone is able to help it’ll be very much appreciated, I’ll attach some screenshots with my setup below.
This is on the begin play of my character. The variable UserData just contains some info on which meshes to use for each body piece.
This is what happens in the true side of the branch, its missing 2 rows but they are identical to the last one, they just set different meshes. The false side does the same but for female parts.
This is the one for Skeletal Meshes, and it just sets the values of the mesh references i have in my character so that they can be RepNotified.
In the RepNotify functions this server event gets called. It’s the same for every RepNotify function that deals with Skeletal Meshes, and another version that deals with Static Meshes.
Skeletal mesh doesn’t replicate. The way I’m doing it on a modular character is to have the server execute a multicast → Rep_Notify. The rep_notify function builds the mesh and sets it.
I found a tutorial on Skeletal Mesh replication and this fixed my setup which is similar to yours albeit less complicated (Thanks for the suggestion RevOverDrive, but the rep notify didn’t make a difference for me).
And FYI, I’ve got my Mesh randomization happening in the GameState so I can be sure that it’s accessible by all players, but in my case, it’s just because I wanted randomization with removal so I couldn’t keep the array of skeletal meshes inside the character. I just wanted to mention it in case you might be trying to execute the code in the wrong place.
And for Posterity in case the YT video disappears in the future; this is the key:
Oh snap! I jumped the gun thinking my issue was solved because I accidentally ran Standalone when I thought I was set to be a Client. So I’m with you, this code isn’t working for me either even though it should. For whatever reason in my case it’s assigning the same mesh to every A.I. in MP.
I’ll look at it again tomorrow. Maybe one of us will figure it out and help the other
Right, I did hear that’s the reason to use RepNotify because Multicast only works when clients are relevant to you at the time of the change. Okay, I’ll try a notify again. It doesn’t matter what the notify is right? I can just use a simple bool and set it to on when I want the change to happen? I think the reason I thought it didn’t work the first time is probably because I didn’t have the code setup properly to begin with. Thank you for your suggestions, I appreciate the help.
The server has authority the entire time so the Repnotify is never called because at each Switch it simply ends the execution. If I remove the Switch Has Auth, the RepNotify is called and all of my AI have no Skeletal mesh assigned. I’ve checked the NewMesh by getting the display name and it is unique, but for whatever reason when I call the Repnotify there’s no mesh assigned.
I don’t understand why you have to do this on the server and the client at the same time. Shouldn’t the server be the one getting the info and then it simply passes that info along to the clients when you request it with a notify or multicast? This doubling up on code seems totally redundant. The whole point of a Multicast is that it happens everywhere. Server and Client. So why on earth would you need to do it on server and then multicast? Multicast should be doing it in one step (and according to my print strings, it is).
In my Game State I turned my “Get Random Mesh” events into Multicast events.
Then in the AI, I stripped out all the extra “on server junk” and just used a Multicast to get the mesh and set the mesh and then called the Repnotify and it works!
Thank you for the help RevOverDrive! I really could not have figured this out without you!
For the sake of discussion here’s some snippets from our prototyping test phase.
Blue section is called off Begin Play in the Character class. We do this so that on level load and character spawns there’s a mesh. Although naked/base model…there’s a fully replicated mesh.
This function builds an array of parts for Mesh Merge, Merges, Validates the Merge, then calls a Multicast ( Srv Multicast Skeleton img 1). Note the Mesh Merge return is passed to the multicast.
Srv Multicast Skeleton event sets w/notify Merged SK Mesh.
I’ve managed to make it work, in the end I chose to set up RepNotified mesh variables since I read that merged skeletal meshes don’t support morph targets out of the box and we plan on using them quite heavily.
This is the final setup for now:
This gets called when the character appearance is selected…
…which then calls this…
…this then finds the correct meshes and then calls this…
I just wanted to post this here for anyone in the future:
I had to re-do my code because of an update to a marketplace asset that I’m using, but when I did so my prior solution stopped working and I couldn’t understand why.
Today I realized that the fix is really simple. Sometimes you need to add a delay between getting your mesh and applying your mesh to give the system the time it needs to execute things properly. In my case I have the selection of which mesh to use happening as a Server Event inside the GameState. Then as each AI is spawned, I get the SelectedMesh from the GameState and then use a RepNotify to update the skeletal mesh for all players.
My code was actually set up correctly, but each AI was being assigned the exact same mesh and I couldn’t fathom why because I knew my code should be working. Then I added a delay of 0.2 seconds between Getting the Mesh inside the AI and Randomly selecting a mesh in my GameState and this fixed the issue.
The reason this fixed the issue is because the the GetMesh code was firing at the same time as the Random selection, so that specific code didn’t have enough time to execute multiple times. By adding the delay of 0.2, it gave the ranomization code time to execute and fixed the problem!