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:
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:
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.
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
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:
maybe this is another thing that could lead to a solution. Thank you guys so much for reading, I hope you can help me :)
asked May 28 '15 at 10:09 AM in Blueprint Scripting
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.
answered May 28 '15 at 01:05 PM
You have 4 pawns. Name it, for example, like this:
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
Follow this question
Once you sign in you will be able to subscribe for any updates here