ActorComponent does not replicate variables to client

Adding an ActorComponent subclass to a replicating Actor does not replicate value changes in the ActorComponent’s variables to the owning client.

Test case:

  1. Create an Actor subclass (called “MyActor”) in blueprints and mark that Actor as Replicates(True).
  2. Create an ActorComponent subclass (called “MyAC”) in blueprints. Add this Component to the MyActor blueprint.
  3. Add a variable (lets say an Integer variable, called “MyInt”) to the MyAC. Mark it as RepNotify.
  4. Put a PrintString node in the OnRep_MyInt that calls Get My Int and prints the value.
  5. In the MyActor EventTick add a PrintString node that gets the MyAC variable and then gets the MyInt variable of that and prints it.
  6. Create an event that modifies the MyAC->MyInt value on the SERVER side.
  7. Notice that the SERVER side value changes correctly and runs OnRep_MyInt correctly, but only on the server.
  8. Notice that the OWNING_CLIENT side value never changes and OnRep_MyInt is never called on the client.

Why would it run OnRep_VAR on the server when the component is not set up to replicate? Secondly, I’m using a custom ActorComponent subclass built in Blueprint as a ‘static actor component’. There does not appear to be a Component Replicates checkmark for my custom subclass. Perhaps I built it incorrectly? The variables in the custom subclass are marked for replication and so is the containing Actor.

EDIT: A quick test shows that the Component Replicates checkmark does not appear in the Class Defaults of a fresh ActorComponent Blueprint. What am I missing?

Right you are! I see that code in the 4.12 code as well. However, here is the Details panel of my ActorComponent subclass’s Class Defaults:

104634-screen+shot+2016-08-27+at+23.54.59.png

This is driving me crazy. This seems like it should “just work”. I really really hope I’m just missing something simple. Otherwise, I will have to wait for a patch from Epic, in which case I might as well build my own engine again…

1 Like

My guess, your actor component is not set to be replicated.

Thats all fine questions, but i dont have expertise for it to answer, only guesses based on my blueprint networking experience and according to it, there are was checkmark in 4.8 for sure, but now its gone, while property suggest its should be there.

ActorComponent.h

	UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Replicated, Category=ComponentReplication,meta=(DisplayName = "Component Replicates"))
	uint32 bReplicates:1;

also its set to be true by default.

Holy crap! After your recommendation, I did a work-around by calling Set Is Replicated in Event BeginPlay for my custom ActorComponent subclass and IT WORKED! Would be awesome to have the checkmark back (hint, hint, Epic), but this will do for now. Thanks for the sanity check and push in the right direction @CriErr

EDIT: This issue is related to https://answers.unrealengine.com/questions/466926/component-replicates-no-longer-displayed-in-editor.html
Please go vote on that issue for a fix!

1 Like