Server side recoil

I’ve been trying to implement server side recoil and I’ve so far had no luck getting it to work right. I’ve been trying to use ClientSetRotation to force the client to update its view rotation, but it’s really not working well over the network when latency is involved. Since the client rotation is behind the server rotation it ends up resetting the rotation when the recoil is applied. How can recoil be calculated on the server? It’s easy to calculate bullet spread server side, because it doesn’t affect view rotation, but doing actual recoil is a challenge. I’ve thought of calculating the recoil offset on the server, and sending that to the client, but there’s no guarantee that the client will apply the recoil to its view rotation. If the client gets hacked to not apply the recoil, then any guns that are supposed to have high recoil to offset their damage will be really easy to cheat with.

Not really. If you apply the recoil on the server anyway, if they hack the client to not apply recoil, they still miss on the server (the firing should happen on the server always).

How would you go about implementing it on the server though? I’ve used AddControllerPitchInput to get it working on the client, but that has no effect on the server.

I’d suggest looking into a seeded random number generator.
UE4 has this built-in in the form of FRandomStream.

By syncronising the seed used by the the RNG between server and client, you can run server side recoil code on the client and should get the same results.

Provided the actual firing is done server side, any hacks to remove recoil on the client would make it more difficult to hit things.