Replicate base class UPROPERTY in subclass only

Oh, I guess “weapon” and “target” threw me. That’s an interesting request.

You should check out the AActor::SetReplicates() function. That will turn replication on and off.

I would try having the base class variable replicated (with the GetLifetimeReplicatedProps entry) and turning it off in the BeginPlay (or perhaps the constructor would work too). Then in the base classes that need replication, just turn it back on.

Another option comes to mind but I’m not sure it will work. You could try having the base class variable not replicated, then turn replication on in the derived class and put the entry in that GetLifetimeReplicatedProps. It makes sense in my head but I’m not sure the engine works that way. You could experiment – because I’m not sure if the class that declares the variable also has to have the lifetime-rep function entry. If not, this method should work.

Or a variation: not replicated in the base class but the lifetime-rep entry is there anyway. Then the derived class turns replication on.

I’ve never tried this so it’s up to testing. But the first option would work for sure.