Replicated variable from Actor Component

I have a Blueprint Actor Component based on a custom cpp Actor Component I'm using with a SCS Hook. The component is set to replicate and it has 1 variable I set to replicate. I populate the variable in a Blueprint and access the variable in cpp. It works fine in Single Player or for a MP host, but when I set the variable on a client and try to access it from the server it is null. Is what I'm trying just not possible or am I missing something?
Solution:
you can just use the Server-bound RPC directly on the component
Jump to solution
19 Replies
Rex
Rex2mo ago
Which kind of variable is it?
SirDigby
SirDigbyOP2mo ago
FFactoryCustomizationData
Rex
Rex2mo ago
Hmmm, do you have a RCO? You're trying to do client ---> server
SirDigby
SirDigbyOP2mo ago
How would I use an RCO for this? I figured the replication would handle it but admittedly I'm a networking novice here
Archengius
Archengius2mo ago
replication happens from server to client not the other way around
SirDigby
SirDigbyOP2mo ago
Ah, that's where I messed up, then
Archengius
Archengius2mo ago
you do not need an RCO either if it's a component on player character, player controller or player state
Solution
Archengius
Archengius2mo ago
you can just use the Server-bound RPC directly on the component
SirDigby
SirDigbyOP2mo ago
How do I do that? It is attached to the player character
Archengius
Archengius2mo ago
the same way you would do it in the RCO: by declaring a UFUNCTION as Reliable, Server
SirDigby
SirDigbyOP2mo ago
In the component?
Archengius
Archengius2mo ago
yes
SirDigby
SirDigbyOP2mo ago
That doesn't seem to be an option, at least not for functions defined in the BP
Archengius
Archengius2mo ago
do you not get function options on the function node or?
SirDigby
SirDigbyOP2mo ago
No description
Archengius
Archengius2mo ago
and your component is marked as replicates
SirDigby
SirDigbyOP2mo ago
Yes
Archengius
Archengius2mo ago
is this a function or an event it needs to be an event i'm pretty sure
SirDigby
SirDigbyOP2mo ago
Ah, ok Yeah, that lets me set those It worked! Wow, this is so much better than the way I used to do thing. Thanks!

Did you find this page helpful?