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