This is for a multiplayer party game where I need someone to type in their response to a prompt and then show their answer to another person.
the string that you want to “send”. in the Details window for the variable have its “replication” changed to the desired effect.
- Replicated: the value will be trusted to be sent, so that it can be referenced whenever, but may not always be up to date given the potential delay between send-receive, and may need to be checked repeatedly for changes
- RepNotify: whenever the value is sent the receiver will be notified that the value is changed, and it can be trusted that the value is “always the most up to date” at point of the notification
for Blueprints the replication happens whenever a Set is performed on the variable, meaning any calls to Set()
or Add()
in particular will trigger the replication.
if the value of the string is to be kept secret until the first user is ready to send it, then a separate WorkingString should be used, and then when the first user wants to send it, copy the value using Set()
to the replication string.
passing strings via replication might not always be very performant especially if the string could be long. it would take a few extra steps, but maybe rapping these into a JSon object, and then sending the JSon object via HTTP, but this runs into potentially giving almost Direct IP access between the system (or clients and servers), and if you don’t sanitize/validate the JSon on receipt you could get JSon code execution which is a security vulnerability waiting to happen.
I’m new to UE and I use blueprints. When you say Set() or Add() are you referring to script or blueprints? If you are referring to blueprints, can you please send an image of what you are talking about?
Hey there @3catboi! When needing to send data between two users in a multiplayer instance, you’re going to need to set a variable (in this case a string) and have it replicated, preferably through the RepNotify mechanism. The Set() and Add() functions Gard mentioned are in reference to how they’d be used in C++, but in Blueprint they’d just be the Set node.
Here’s a tutorial:
Disclaimer: One or more of these links are unaffiliated with Epic Games. Epic Games is not liable for anything that may occur outside of this Unreal Engine domain. Please exercise your best judgment when following links outside of the forums.