Download

[HELP] Multiplayer projectile replication

Hi all,
I have the following blueprint to handle my multiplayer shooting for a FPS.

(No dedicated server)The problem with this is that the clients can only see server projectiles. Clients can see their own projectiles, but not other clients. The server also can not see client projectiles. I tried the blueprint without the switch has authority, and it produces the same result.

Thoughts on how to fix?

Spawn Projectile from the Server only, not Multicast.

When I do this, only the server player (again, listen server) can spawn projectiles. Clients are unable to spawn projectiles (and thus fire their weapon)

RPC to server to fire weapon (spawn projectile) -> Multicast to clients.

This produces the same result as the previous response… thoughts?

You got it backwards.

The client input needs to call a RunOnServer event when shooting begins
Then the server spawns a replicated projectile and that’s it. Now the server can finish by replicating the projectile actor to the clients.

What you have right now is a RunOnOwner RPC that can only be called by the server.

To hide the input-lag on the client doing the shooting you should “predict” the shot on the client and play the sound for the shooter. The other clients should hear the sound when the projectile spawns or on impact.

  • First of all you need to run the “spawn actor” node in a “run on server - reliable” event.
  • The Other stuff you’re doing, like the Montage Play, can be added in a Multicast event that you call after the run on server event
  • Make sure the projectile bp is set to replicate and replicate movement. I would add a “Set Replicates” node on the spawn actor node as well.
  • Maybe it helps if you enable “Replicate component” on the individual components in the projectile bp. for example, enable Replicate component on the mesh, on the projectile movement component, on any attached particle systems etc…

Just giving my thoughts of what I can think of here. But yeah, replicating projectiles can be troublesome, I’m still having trouble with it as we speak. I still don’t have my bow arrow projectiles replicate properly after trying for a week, but at least I got it working to some degree.

Here’s a little image to help:

It’s a design pattern for networking stuff

When you spawn replicated actor you do not need to Multicast. Spawn it only on the Server. Just make sure that your projectile is replicated.
Note that the server needs to know your muzzle location or location from where you spawn the projectile.