I have been playing around with [Physics based UFO content example] and would like to know if anyone has any ideas on how to make it multiplayer enabled. I have modified the original BP a little bit to have 6 DOF movement but most of it is unchanged.
I tried adding velocity and rotation on server but and the movement replicates on both server and client but it makes the client controls very jittery. [Video of the jittery behavior]
Is there a better way to do this for smoother results on the client that replicates client positions/rotations to the server?
Part of the blueprint that handles server events:
I would not replicate the actors movement but call the function which defines it’s movement on both - client and server (or multicast everywhere). you could also create some ease in function which corrects positional drifts between server/client with a lerp or ease function to make sure the positions are ok. they way you do it will network replicate the position every tick. have a look at the character movement component - they only replicate like “forward button down” … “forward button up” - and not the position itself (as far as I remember)
So I found this post after I posted this. I tried to follow what zeroexception posted and implemented it into my blueprint. I am setting the Physics Linier Velocity and Add Actor Rotation on both the server and the Client in the same tick but I turn off movement replication on the client before I set the velocity or rotation. I have a position vector and a rotator variable being set by the server that are set up with RepNotify. The rep notify function on both of those fires a client side only update to interpolate to the new position and rotation set by the server. Now this seems to work pretty well and it seems with jittering only occurring when I simulate high latency like 1k+ plus or packet loss. Even then the only thing that stutters is that client rotation sometimes goes out of sync and makes the client jump to server rotation when it syncs up.
I am still new to this so I am not sure if this is the right approach. Since I am doing this on every tick I am concerned that it might be too much from an optimization perspective? What are your thoughts on this approach?
I will give the C++ solution that zeroexception posted a shot as well once I get a better grasp of the engine.
Thanks for responding.
Here’s a screenshot of my implementation.
depending on your conditions how the result game should look like (how much clients for example) this should be ok. remember, you can set the tick interval in the actor and what I usally do - on begin play I create a few timers which tick not every frame like every 0.5 sec, every sec, and so on - in this events you can adjust positions or rotations with some interpolation that this “milestones” are not too frequent but keep the client on track with the server without drifting too much out of sync (you could also check how far they are out of sync and after a certain value force them to sync). I’m just curious about your camera events - I don’t think this should be something network related but a client only management thing - but maybe you have a usecase for that
I will play around with timing like you suggested and see how it works out. Camera is 100% client based. I had just named it incorrectly in my initial screenshot. Camera components are not replicated to the server at all. Just the rotation from input is replicated for actor rotation.
Thanks again for your response!