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?
19 Replies
Which kind of variable is it?
FFactoryCustomizationData
Hmmm, do you have a RCO? You're trying to do
client ---> server
How would I use an RCO for this?
I figured the replication would handle it but admittedly I'm a networking novice here
replication happens from server to client
not the other way around
Ah, that's where I messed up, then
you do not need an RCO either if it's a component on player character, player controller or player state
Solution
you can just use the Server-bound RPC directly on the component
How do I do that? It is attached to the player character
the same way you would do it in the RCO: by declaring a UFUNCTION as Reliable, Server
In the component?
yes
That doesn't seem to be an option, at least not for functions defined in the BP
do you not get function options on the function node or?
and your component is marked as replicates
Yes
is this a function or an event
it needs to be an event i'm pretty sure
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!