I am making an action game where I believe fluid movement is really important. Players can run around, jump, get thrown around with explosion etc. I initially tried Photon Transform View Classic and Photon Transform View, with various different settings but none of them worked like I wanted them to. Short video of my issues shown here. Since Photon devs themselves think that the best solution will be my own implementation, I thought I would try it out.
I mostly followed this Lag Compensation guide by Photon PUN here to setup my scripts. I started using this script instead of the Photon Transform View Classic, and my players were successfully being updated in both screens (albeit still laggy…).
On this video, changing sterilization and send rates are mentioned. The author says that this is a really costly and bad idea, though it should be noted that this video is almost 3 years old.
I personally tried setting them to really high values to just see:
void Awake()
{
rb = GetComponent<Rigidbody>();
PhotonNetwork.SendRate = 60; //Default is 30
PhotonNetwork.SerializationRate = 60; //5 is really laggy, jumpy. Default is 10?
}
The movement is definitely smoother, I wouldn’t say perfect but better. But at this stage I’d like to ask folks who probably know better than me:
Is this a bad band-aid solution? Should I try to make my own interpolation/extrapolation system somehow? Will this high send/serialization rates cause issues down the line (it seems fine with 2 players)?
I guess the you made each client calculate their own movement and sync it with photonTransformView.
You want to the other clients see you moving smoothly, but making the send rate higher is not a very “elegant” idea.
Instead, if you want smooth movemet, make it that instead of directly sync the movement, sync just the position and use Vector3.Lerp to interpolate between the old and new positions.
Do you suggest doing this lerping via the Transform View Classic, or implement it in my own way? Because I tried lerp and although it looks smooth if I am just running around, it doesn’t look smooth at all if I suddenly jump or blast myself with a bomb etc.
I also want to add, when I just use the new Photon Transform View it works pretty well in the horizontal movement, almost perfect. Only problem is if I jump (or launch myself up in the air) I am jittering up and down like crazy
I actually fixed this issue syncing rigid bodies instead. The solution works perfectly for me, instead of writing a whole bunch I’ll just link my video where I go over the changes.
Apologies for necro’ing old thread, just wanted to share thoughts. Yeah I think one of the main fixes here is actually syncing the rigid body state so that in-between network updates (by default 10Hz for Photon serialization I think) the physics engine properly moves the rigidbody (physics runs at 50 Hz by default).
Photon provides a PhotonRigidbodyView component which handles syncing the rigid body’s velocity and angular velocity so people viewing this thread can try that out too.
The lerp part of the solution shared in the video seems less likely to me to be the main fix as that’s equivalent to just applying an IIR style filter to the movement which I guess could make it smoother, but the original PhotonTransformView code already scales the value it does MoveTowards by the distance between the current position and the target position (effectively linearly interpolating between the two values across 1/PhotonNetwork.SerializationRate seconds).