Disable replication on character component

Hi,

I’d like to know how to stop a component from replicating over the network. More specifically my camera spring arm and camera.

Here is a snippet in my MyCharacter.ccp:

this->CameraSpringArm->SetIsReplicated(false);
this->Camera->SetIsReplicated(false);

Here is a snippet in my class extending USpringArmComponent:

this->bReplicates = false;
this->SetIsReplicated(false);

(This second snippet is called both in the constructor and in a function called in the Character’s constructor)

Right so, with all of this code it should stop the component from replicating, right?

Well not so fast!

I added this code to my TickComponent:

if (GetAttachmentRootActor()->Role == ROLE_Authority) {
      LOGWARN("Ticking from server");
}
else {
       LOGWARN("Ticking from client");
}

And sure enough, when running the game in PIE with dedicated server ticked, what do I get? Both lines! God damit :frowning:

Am I missing something here?

From Component Replication | Unreal Engine Documentation

“Static components are components that are created when the Actor is created. That is, when the owning Actor is spawned on client or server, these components are also spawned, whether the component is replicated or not. […] Static components do not need to be made to replicate to exist on clients; they exist by default.

I assume that your actor is spawned on server and client with replication, otherwise you would probably not want to disable replication for a single component. This means, that your component exists both on server and client and both call the tick functions. I would guess that’s why you get both lines. With your code these two components (one on server, one on client) are just not communicating with each other.

Ah I had forgotten that!

Thanks!