Download

Is replicating a boolean for "isShooting" good practice and responsive enough?

Let’s say I want to have a player shoot while mouse button 1 is held, which is a boolean replicated to the server which spawns a projectile every few fractions of a second while held. This boolean can also be replicated to the character actor in the other clients to do some cosmetic things like animations or sound while firing.

I want to know if you feel this is the best way to accomplish such a common situation. Is setting it through replication responsive enough? Or would an RPC be more responsive? Do games often have to add their own client side predictions to get a responsive feeling upon shooting?

You can’t replicate anything from a client to a server, replication is when a server “replicates” a variable to a client.

The input from the Client would be sent by an RPC to the server like BeginShooting and EndShooting.

Then the Server would spawn a replicated projectile.

When the projectile is replicated to the other clients it can trigger the shooting effects like animation and sound.

RPC vs Replicated variable has nothing to do with responsiveness. Every Actor has a NetUpdateFrequency which is used both by RPC’s and replicated variables. If you really have to you can always use ForceNetUpdate at the expense of performance.

Client side predictions is necessary if you want a responsive feeling since waiting for the round-trip before getting the shot is very annoying.