How to Properly Replicate a Custom Actor Component in Multiplayer (UE5)

Hi everyone,

I’m working on a multiplayer project in Unreal Engine 5 and I’m having some issues with replicating a custom Actor Component. I’ve created a custom component (in C++) that handles some gameplay logic (like inventory, stamina, etc.), and it’s attached to my character class.

I’ve already set SetIsReplicatedByDefault(true) in the component’s constructor and made sure the owning actor is replicated. However, the variables inside the component are not syncing correctly between server and client. I’ve tried marking them with UPROPERTY(Replicated) and implemented GetLifetimeReplicatedProps, but it still doesn’t work as expected.

My questions are:

  1. Is there anything specific I need to do to replicate a custom component properly?

  2. Do components need to be registered or initialized in a special way to support replication in multiplayer?

  3. Are there common pitfalls or best practices when replicating data inside components?

Any help or pointers would be greatly appreciated. Thanks!

I use replicating components all over the place. No issues so far. AC set to replicate, and all variables in it set to replicate as needed. For example my inventory AC is in the Player Sate.

Only hitch I see with doing it in the character is if variables are replicated before the client gets and initializes its copy of the character. It could miss an update or two. Once ready though it should be fine.

did you add the DOREPLIFETIME macro?