x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

What is the best way to replicate a value that changes often?

Basically I want to replicate the location and rotation of a Pawn, that does not affect gameplay. It's just so that the players can see each other. So I need to replicate the value from the client controlling the Pawn to the server. From there I also need to replicate the value to the clients.


So what would be the best way to replicate the value from client to server?

  1. Reliable Function every tick (definitely not)

  2. Reliable Function when the value changes (probably not, because location in my case changes quite often, but rotation shouldn't change as often)

  3. Unreliable Function every tick (less network load and completely reliable)

  4. Unreliable Function when the value changes (not as reliable, because the latest update might not arrive on the server)

  5. Reliable Function every 0.1 seconds if the value changed (reliable, slim network load, looks ok if I interpolate the location on the clients, but adds an extra delay of about 0.1 seconds)

  6. Unreliable Function every 0.1 seconds (reliable, slimmest network load, extra .1 second delay)


Secondly, what would be the best way to replicate the value from server to clients?

The possibilities are pretty much the same, with the exception, that I could also use a replicated variable.

I guess the question really boils down to how do reliable functions compare to unreliable functions? And how do replicated functions compare to replicated variables in terms of network load? Maybe some of you have a rule of thumb, that they would like to share.

Product Version: UE 4.13
Tags:
more ▼

asked Sep 27 '16 at 03:47 PM in Using UE4

avatar image

AllJonasNeeds
249 26 36 71

avatar image AllJonasNeeds Sep 27 '16 at 03:57 PM

Also, is it possible to use the normal replicate movement flag for this? Maybe it is possible to override a function, that handles the movement replication? Then I could override that function and stop it from executing on the client, that controls the Pawn.

Edit: I could override AActor::PostNetReceiveLocationAndRotation() to achieve just that. So I am pretty sure the best way to Replicate from Server to Clients is to use the standard Movement Replication.

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

I am pretty certain what the best solution for my case would be and what I am going to do. But keep in mind that this solution is not the best solution for every case, so try to consider all the different options in your case.

So for the server to clients replication, I will override PostNetReceiveLocationAndRotation() on my Pawn, so that the Client does not do anything, when he receives an update, since the Client acts authoritative in my case, because the Pawn has no direct Gameplay impact, like the observing Pawn in a strategy game. So that method would look something like this:

 void AMyPawn::PostNetReceiveLocationAndRotation()
 {
     if (!IsLocallyControlled)
     {
         Super::PostNetReceiveLocationAndRotation();
     }
 }

For the replication from the client controlling the Pawn to the server, I will use an Unreliable Function every tick. But I will also keep track of how often the function was with the same Location value. Kinda like this:

 pseudo code:
 
 uint8 LocationUpdateRepititions;
 
 if (LocationChanged())
 {
     SentUpdateToServer();
     LocationUpdateRepititions = 0;
 }
 else if (LocationUpdateRepititions < 10)
 {
     SentUpdateToServer();
     ++LocationUpdateRepititions;
 }

Of course I would have to change the Threshold based on how well this works.

more ▼

answered Sep 27 '16 at 05:18 PM

avatar image

AllJonasNeeds
249 26 36 71

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question