I have an actor that is thrown from a character. The actor replicates fine to other clients and it moves smoothly, but it doesn’t replicate the movement. If I put SetReplicatingMovement(true), it replicates the movement fine, but then the movement of the actor is very choppy on other clients machines.
How can I replicate the movement of the actor while keeping the smooth behavior?
a) what movement component are you using? (Floating, Character, Vehicle, Custom?)
b) what method are you using to introduce the movement? Add input, change of velocity, are you changing the character location?
c) Are you making changes on the client or server?
You could be setting different values on client and server and then the client might be fighting the information it receives from the server making it jittery.
If it has the character movement then use add input on the character.
a) No movement component is used. The actor is a bomb that attaches to a character.
b) When I release the bomb, I first detach it from the character using the DetachFromActor function. I then do GetItemMesh()->AddImpulse() to throw the bomb
c) I run these functions in a multicast. I don’t want to do it only on the server because if there is significant lag, it won’t be a good experience for the player. I want to throw it both locally and on the server. I guess some kind of client-side prediction is needed?
If you are going the route of multicast then you would need the motion to be deterministic to have the same outcome on all clients (not in the case of ue4’s physics).
In this case you are replicating the object → server is tracking the location / rotation / scale and you are simultaneously giving it separate orders from the multicast.
So the bomb is constantly self correcting for motion it receives from the server.
There are network predictive algorithms in the engine in an experimental phase so they are not production ready.
You could try turning off movement replication just before the impulse and once it comes to a halt, re-enable it, but this might cause position snapping / rubber banding.
Personally I would try using “Predict Projectile Path” to get the motion on the server and maybe send out the vectors to the clients and have them play out the motion locally or just do it solely on the server (at least the client wouldn’t fight the server for dominance).
Multicast is mostly used for non-critical effects / sounds.
Also this GDC talk might help you
Tutorial is a little long but projectile movement with set velocity can also work in mp
Though part way through he should have passed in the player character and add it to the grenades ignore actor when moving list instread of moving the start offset. Didn’t watch all the way through but the mp part seemed reasonable.