Replication of Character Ref in Player State

I think I’m improperly using a reference to the player character inside the player state to replicate character customization.

In the player character BP I created material instances.

I created an actor component, named it character customization, and added it to my player state BP.

In the character customization component I added a replicated reference to the player character, and rep notified colors.

In the player controller on possession I get the player character and set the player character reference in the character customization component.

When the player spawns colors are pulled from the saved game and set on the server in the character customization component.

On rep for each color I get the character reference, the appropriate material instance, and change the color.

Everything works great until I spawn in the host, run far away, and then spawn in the client. The host’s custom colors never show, even if the client runs over to the host.

I tried setting the character BP to always relevant just to test culling and that didn’t help. I checked the validity of the character ref in the character customization component, and that is returning false for the host when the client spawns far from the host, but true when the client spawns near the host.

So it still seems like a culling distance issue, but maybe it’s actually a timing issue? Is there a better way to reference the character from the player state? Or is there a better way to reference and change the color of the material instances following the rep notify of the custom colors?

I think the issue is caused by network relevancy and replication timing. The PlayerState is replicated to all clients but the player character is only replicated when it becomes network relevant. So, when the client spawns far away, the host’s character might not exist on the client’s side yet. The customization color data arrives but the character reference is invalid, so the colors aren’t applied. When the character eventually becomes relevant, the OnRep doesn’t run again because the color data hasn’t changed.
Moving the character customization component from the PlayerState to the player character would be a good idea. You can keep the customization color data in the PlayerState but let the component on the character handle applying those colors to the materials.