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"

Understanding replication in blueprints

Hi, this question pretty much refers to my question from yesterday: https://answers.unrealengine.com/questions/233981/use-replication-to-move-an-object.html But I guess this is the key to solve it and it might be easier to have a look on it without the whole content of my project in the other question. But I will add a comment there refering to this.

To get started: I made a pretty simple level, looking like this:

alt text

I created a simple pawn (in fact it's just a camera) that will do nothing but looking to the wall (and the Text) and recieving an input if the F-Key is pressed:

alt text

If the key is pressed the pawn causes an event running on the server that decrements the value that is displayed on the text render actor by 1. The value is set on "Replicated". Now there is the part where i guess the failure might be located but I am not sure about that. My Gameinstance is storing a reference to a Text Render Actor (called "Text1"). In the LevelBlueprint I set this actor as the (only) Text Render Actor on the Map.

alt text

If i run this project (Press "Play" with 2 players as settings) the following happens: if I press "F" in the client's window, everything is fine. In both windows the displayed number will decrement. If I press "F" in the server's window, nothing happens. OK, that's not true. I watched the values in the debug view. As you can see below, there are 4 Pawns I can watch

alt text

I guess this is OK, I got 1 Pawn for every Player in every window (so I got Player*Player Pawns in general). If I press F - no matter where - 2 of the Pawns (one in each window) will capture the decrementation, the other both stay. Why don't the raplication cause them all to have the same value? There is one other thing comming to my mind: To get started I followed the official Epic games blueprint network tutorial and there everything worked. If I watch values in the debug mode there, 2 of the Pawns got the same name:

alt text

maybe this is another thing that could lead to a solution. Thank you guys so much for reading, I hope you can help me :)

Product Version: UE 4.7
levelsetup.png (436.9 kB)
mypawn.png (217.2 kB)
levelblueprint.png (78.5 kB)
pawns.png (6.4 kB)
pawns2.png (8.0 kB)
more ▼

asked May 28 '15 at 10:09 AM in Blueprint Scripting

avatar image

22 7 10 13

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

2 answers: sort voted first

Ok now I got it: I have to realize the whole global variable stuff with GameState and everything is fine. Thanks for answering, you helped me a lot to understand how it actually works.

more ▼

answered May 28 '15 at 01:05 PM

avatar image

22 7 10 13

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

You have 4 pawns. Name it, for example, like this:

  1. PawnS (original server) - server player
  2. Pawn1 (original server) - client1 player
  3. PawnS_RC (Replication Copy on client1)
  4. Pawn1_RC (Replication Copy on client 1)

Your action:

 1. You play on client1 and possess pawn1 on server
  2. You press F, call event "F Input" inside Pawn1_RC. Pawn1_RC try to call 'Call Decrement' - server version. And this event called on Pawn1 (original server). Value was decreased inside server original instance of YourPawn class (Pawn1 in our list)
  3. Var "Count" inside Pawn1 changed, var "Count" inside other instance of class like "PawnS" still same.
  4. Pawn1 replicate its vars to their clients copy, so Pawn1_RC on client1 also change. PawnS_RC not change because its server original not change.

2 pawn changes, 2 - not. As expected.

What about Text? Dunno. Both pawn actially on every tick set Text value. And one of pawn have decreased value, while other - not. What value you see - i think its depend order of ticks.

I think server pawn spawn first, client1 spawn second (on connect). So they tick same order. Server tick first and set var with server value, then client1 tick second and overset var with client value. So you always see client value and never see server value.

Instead of level text you can add "Text component" inside pawn and set it. So you can see pawn value on each pawn independently

more ▼

answered May 28 '15 at 11:33 AM

avatar image

451 13 7 27

avatar image TGE May 28 '15 at 11:55 AM

Ah, it makes sence that the client's window only has copy's. At least I understand this now. So the question should be: How can I make PawnS to take the new value if changed in Pawn1, too? I guess I have to get the value out of the Pawn and make it like global? How do I do this?

avatar image Detech May 28 '15 at 12:02 PM

You can try create function like "SetSomeValueOnAllPawn(int32 value)" and change actial var on every pawn in list.

Forexample you can use Get All Actors of Class https://docs.unrealengine.com/latest/INT/Gameplay/HowTo/FindingActors/Blueprints/index.html

find all yours pawn (on server) and change var inside every pawn you find.

If you change value inside every pawn on server - they all replicate values on every client copy they have.

About global vars - you can place var in "GameInstance" or "GameMode" (exist only on server) or "GameState" (exist both server and clients and can be replicated). So your "Call Decrement" function must use sequence like this - "GetGameState"->"Cast to MyGameState"->"Set Count"

(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