Replicate actor to all - but replicate internal variables to owner only?

[Blueprints] -
Is there a way to ensure that references to actors and objects are maintained and replicated, but their internal variables are only replicated to the owners of that actor? For example:

I’m developing a strategy game where players construct city entities on a global map. Having the servers reference to those actors replicate is so phenomenally convenient that it’s hard to put into words, but I want the internal data (technology levels, income, civilian count, etc) to only be replicated to the owner of that object - as this data gameplay wise is supposed to be kept secret from other players.

A possible solution I have at the moment is that only references and actors are replicated, but none of the internal variables are (aside from cosmetics), and that the owner is then given additional information in an event issued from the server.

I can’t shake the feeling that there is a better solution then that however. Thank you for any advice you can give.

Each variable has it’s own replication settings.

If you replicate an actor it will only replicate the position, collision / shape and such. Not variables within the class.

Am I able to set the replication settings of those variables to owner only in blueprints?

I think the c++ equivalent would be: DOREPLIFETIME_CONDITION( AActor, Property, COND_OwnerOnly );

I would honestly suggest watching this series:

It’s a few tutorials by epic showing you all important settings to get you going.

But the short answer is yesish.

Could I trouble you for a brief description of how to do it?

Thank you for the link, I’ve watched the series before, and just re watched 2, 3 and 4. To reiterate, I would like to know how to make some variables of a specific actor replicate as usual, but some of them to only replicate to the owner.

I’ve just looked into another project again and it really didn’t have the option to replicate a variable to owner only and we actually added that ourselves… and used it ever since in every new project :confused:

Sorry. So for an immediate fix the question is what variables / how many and is C++ impossible?

If this is only about a few specific variables replicating them via events might work just fine.

For more in BP only a second actor set to replicate to owner only can work too.

Otherwise it does really make sense to either just set up the variables in a C++ class or add “Replicate to owner” to the list in blueprint if you can manage that.

“Sorry. So for an immediate fix the question is what variables / how many and is C++ impossible?” - c++ isn’t totally out of the question, I just really wanted to avoid it because I’m a garbage coder, but knowing that it’s the solution your team went with gives me peace of mind that it’s probably the best answer. One variable at the moment, a struct of int’s, but I doubt that this will stay the only owner only variable for very long.

Could you give me some advice on how to go about adding the Replicate to Owner functionality to the Replication list? Will I need to build the engine from source etc? Thank you very much for your advice so far!

I honestly don’t know. I primarily work on gameplay itself and not tools / systems :confused:

This pull request does exactly that: https://github.com/EpicGames/UnrealEngine/pull/1355

Thank you so much CodeSpartan!