I am having hard time undestranding the OnRep_ServerState




This is very great tutorial and very important one! So I have been trying to get grasp of everything before moving to next lecture. This one is giving me a headache.

So I think I undestand everything to the point where server changes the ServerState variable. So when server changed the variable, OnRep function is run on clients, right? What I don’t undestrand is why we ain’t experiencing the glitch?

The function starts with:


Doesn’t that mean that we would first experience the glitch jump when we set the position where the server tells us? Why we run this function first?

Next we are are setting velocity that is all good.

Velocity = ServerState.Velocity;

Next. we are are running the


What exactly is happening here? The function says that if our move timestamp is bigger than the server one we create a new array of that. I still don’t undestrand what kind of moves are in the new Array, could you give more clarification about that? After we have created new array, we foreach that new array and run SimulateMove for each array index. I don’t undestrand how we get the effect we have by doing that (removing the glitching)?

That bring me back to first question: Why we are doing this in beginning?




No, because we haven’t rendered yet. Remember, everything that happens in your code is single threaded and happens before rendering.

By creating a new array we are effectively removing all the moves that we (the client) know the server has already applied.