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"

Replication happening too slow, even with ForceNetUpdate

 // IsTagged is a replicated variable
 myPlayerState->IsTagged = true;
 myPlayerState->ForceNetUpdate();
 // NetMulticast function
 myCharacter->OnPlayerStateUpdated();
 
 // so we set IsTagged true and it is replicated eventually, 
 // we then have all clients' versions of the replicated character check its latest state
 // which should be IsTagged = true, but it's not until after the OnPlayerStateUpdated event happens
 
 void GameCharacter::OnPlayerStateUpdated_Implementation()
 {
     if (Role != ROLE_Authority)
          check(myPlayerState->IsTagged);
 }


Product Version: Not Selected
Tags:
more ▼

asked Oct 13 '14 at 07:39 PM in C++ Programming

avatar image

Cobryis
452 33 17 46

(comments are locked)
10|2000 characters needed characters left

4 answers: sort voted first

Okay, my old solution wasn't really correct. The correct solution is to have things occur when the variable changes for the client. The reason I was sending an RPC after setting a replicated variable was to let the client know stuff had changed, and the reason I was doing that and not OnRep was because I was letting the Controller know that the PlayerState had changed (or really, was going to change) since I already was referencing the controller. I restrategized and moved state stuff that the controller was dependent on out of player state and into the controller. The player state doesn't need to update that quickly, but the controller does.

more ▼

answered Nov 05 '14 at 05:20 PM

avatar image

Cobryis
452 33 17 46

(comments are locked)
10|2000 characters needed characters left

I'm not sure if this is the same problem you had but they sound similar. In my case I made a custom PlayerState class and added a "points" replicated variable (since score is read only for some odd reason.. but that's a whole seperate issue)

so i bound a key to make a server call to add 50 points everytime i pressed it. And i was drawing the value on the hud every frame yet I noticed the points updating seemed extremely laggy.

Turns out while most actors have replication "Net Update Frequency" of 100 times per second PlayerState is set to 1 update per second.

I just bumped PlayerState Net Update Frequency to 100 and everything worked exactly as i wanted. The down side is you may be replicating things like small changes in players ping needlessly as that's something you would probably only want sent like once per second.

So when all is said and done, Due to the constantly changing ping values and because I think in most cases player scores don't need to be updated more than once a second I think it's a good idea to leave PlayerState at 1 update per second and put values you need updated more quickly somewhere else.

more ▼

answered Jun 27 '16 at 12:17 AM

avatar image

tmek
404 30 95 63

avatar image Acriax Nov 28 '17 at 05:39 PM

I just ran into this exact issue. Thanks for helping me narrow it down! However, I noticed that a probably better solution to this is to call a "Force Net Update" node (if using BP. There's most likely a c++ equivalent) right after you set the new score variable.

(comments are locked)
10|2000 characters needed characters left

Well I went ahead and 'solved' this by making the variable not replicated by the engine but instead by reliable RPC.

more ▼

answered Oct 20 '14 at 04:09 PM

avatar image

Cobryis
452 33 17 46

(comments are locked)
10|2000 characters needed characters left

Yeah, your approach wasn't correct. You should have either used an OnRep on the player state that called the function on your character or used an RPC. There's no guarantee that a variable and RPC will happen in order

more ▼

answered Dec 07 '15 at 08:03 PM

avatar image

joeGraf STAFF
1.5k 35 12 67

(comments are locked)
10|2000 characters needed characters left
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