Actor component doesn't replicate

Hi everyone :slight_smile:

I’m currently working on a multiplayer shooter, and I’m trying to implement weapons. To do so, I wanted to use actor components, so I created a blueprint that is a subclass of Actor Component.
In my actor blueprint, I did this:

294971-actor.png

In my actor component, I tried this:

The problem is: my component doesn’t replicate :frowning: The “SERVER” log works fine, but there is nothing on the client logs. Same goes for the “TIIIIIICK” log (on the server but not on the client).

In my actor class defaults, I checked the “Replicates” bool, and I did the same with the “Component Replicates” bool in the component:

294974-actor-properties.png

294973-component-properties.png

Am I missing something?

Thanks in advance :slight_smile:

Syalen.

Well, I managed to understand this.

This behaviour is apparently normal, because you have to spawn the Actor Component on both client and server side in order to have it replicating.

One detail that isn’t: you absolutely have to spawn the component on the server and on the client with the same node. This is how the engine knows that it’s the same component!

So I suggest to have a replicated event (multicast, executes on all), that calls the “add actor component” node. That way, if you call your replicated event, it will be the same node on the server and on the client, so the actor component will replicate.

If I’m wrong or if I missed something, please tell me :slight_smile:

Syalen.

4 Likes

im not sure, but i think that if you spawn the component on the server (only) and set it to replicate, then unreal will spawn it on the client as well.
so technically you don’t need an rpc.
im not sure so i’d be happy to know if that’s right or not.

There was an issue at one point (5.0, 5.1, 5.2) cant remember the version where AC’s wouldn’t replicate.

The work around is to call a multicast to spawn the AC. This all has to happen server-side.

FYI, regular replication is mostly RPC’s anyway, so creating a multicast is really no different than what the engine is doing normally.