Spawning a projectile on server is laggy on the client
I have an actor that spawns on the server, and as you know what ever you spawn on the server will spawn on the client.
This is a rocket, and it looks smooth in the server window, but on the client it is very choppy.
How can I synchronize the positions on the client, so it looks smoother?
I'm happy with theoretical answers.
asked Apr 13 '16 at 07:31 PM in C++ Programming
You should simulate physics on the server only and store the transforms of the server side version actor in a replicated variable.
Then on the client side versions of your actor you can Lerp smoothly from the client side actor's world transform to the server side actor's world transform (which is stored in the replicated variable). This way you don't want to enable built-in movement replication as you have your own replication for that.
Sorry for Hungarian notes on the picutre, initially made this for someone else.
Pink note: If I'm a server side clone, I let simulate physics. (by default, I turned off physics simulation on the actor)
Gray note: If I'm a server side clone, I store my transform in a replicated variable.
Blue note: If I'm a client side clone, I smoothly interpolate my transform to the server side clone's transform.
Using Switch Has Authority to check if it's a server side version (Authority) or client side version (Remote).
Edit: I see you use C++, you can apply the same in code as well if you don't want to use blueprints.
Follow this question
Once you sign in you will be able to subscribe for any updates here