Lag compensation works weird - Photon

This is how local player looks like - as it should:

https://gyazo.com/c565aacf252a6fefed8cbabb3c133d6b

This is how the other player sees him: (it’s like his position is devided by some number)

https://gyazo.com/51e6f2ad23c5727e078e4e4c7d77a252

Player Code: https://pastebin.com/FePpxyBH

Please help.

Took a quick look, and I’m guessing you’ve got 2 issues. First is your lerp code, specifically this:
(float)(currentTime / timeToReachGoal

The above should resolve to a value between 0f and 1f, basically a percentage value. But plug some reasonable numbers into currentTime and timeToReachGoal, and it doesn’t end up between 0 and 1. For example, the game has been running 10 seconds, so currentTime is 10f. New packet comes in 0.1f after the last one, so timeToReachGoal is 0.1f. Your math then works out to 10f / 0.1f = 100f, which is not between 0 and 1.

The second potential issue in your code is it looks like you don’t necessarily complete the previous lerp between the two positions, instead when you receive a new packet you act on it immediately, using the client’s current position for that object as a starting point. I think this is going to lead to choppy movement on clients when packets don’t arrive exactly on time. Sometimes when a packet comes in late, the object will stop moving as you wait for a new packet. When packets come in closer together, the object will appear to speed up on the client. This is making the problem you’re having worse right now because you’re never reaching the end point of each lerp, putting the client further and further away from the next packet’s end point.

I don’t use photon in my game, but the way I handle this kind of this is I queue up data from new packets and don’t act on it until I complete processing the previous one. I send timestamps from the server in the packet so I can track how long it was on the server between packets. I keep track of how long the queue is on the client side, and if I start getting behind I speed up the client side movement by about 10%, and if I get ahead I slow down movement by about 10% or so. I also lerp between positions sent by the server, not the position the client currently has. Just a suggestion

Thank you so much. Do you have any suggestions to fix this?