Announcement

Collapse
No announcement yet.

Variable Server->Client (RepNotify?) Questions

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Variable Server->Client (RepNotify?) Questions

    Hello!

    This is possibly an easy question to answer..,

    I have a multiplayer game im creating, but I have stopped trying to figure out the best way to make this:

    I have a repNotify variable HP, MP, SP (which I want the player, and other players to know about) .. On the other hand, I added a new variable, "Strength" but I want it only the player (me) to know about it, since its useless to let others know my strength: I am the only one that will use it (when equipping items, for example). The thing is, if I dont set it to RepNotify, when Im receiving the info from the database (server-side), it just wont update on the client (I guess it updates the server, since the server is receiving it, but since its not RepNotify it wont notify the client of the Strength received)

    I'm just wondering if theres a way to set this up manually. My guess is possibly a Custom Event with Run on Owner Client? (might not be possible since I receive the info in a function, not event graph, and you cant put customevents in functions).

    Please correct me if I'm wrong or any other suggestions (sending the stat one-time-only *or when I want to* from server -> client)

    Regards & thank you!

    #2
    Hey there,

    1. Variables need to be set to Replicate OR RepNotify to be replicated from Server to all other Clients that share the replicated Actor
    2. Only the Server can set these variables. He's the authority and clients can't change the variables (at least not to be broadcasted to other clients)
    3. Replicate will just take care of the above
    4. RepNotify will also add a function that will be called once the replication is done. So you have a function that you can use to make sure the variables is replicated before calling specific code
    5. Blueprints do not support different condition in terms of replication. If the Actor is replicated to all clients (There are settings in the Class defaults to only replicate an actor to the Owner, like
    the PlayerController does), the variable will be replicated to all clients. C++ DOES support these condition though.

    5.1 You can create a CustomEvent with "RunOnOwningClient", to only pass the information to the specific owner of that Actor. Make sure the owner is properly set to the Client you want it to be.
    5.2 The variable should then NOT be set to replicate of course
    5.3 The CustomEvent can only be created in the EventGroup, but can be called in every other function.

    So if you receive information on your server in function XYZ. You can call CustomEvent (RunOnOwningClient) "Client_XYZ" and pass the client that information.

    Other than that, you can only switch to C++ and handle Conditions for replications there.
    Open for contracted work | C++/BP (incl. Multiplayer) | Tutoring | VR

    My UE4 Blog/Page with Tutorials and more: Hit me for ALL the things!
    (Including 100+ Pages Multiplayer Network Compendium to get you started.)

    Comment


      #3
      Thank you!

      Comment

      Working...
      X