[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.

Ok, I have tryed all of this stuff but none work. And they are not many tutorials that help you with this issue. I am trying to make Multiplayer shooter game and the this is the curremt situation:

If the server shoots a projectile all the clients see it which is good it works
but if the clients spawn projectiles only the owner can see it, other clients and the server can not see it so i do not know what to do. Please help me out.

Hi, your issue has been answered above:

So you don’t spawn projectiles on a client, always on the server. Client calls RunOnServer event → server spawns projectile.

If you spawn something on a client, then all other clients and server will never know about that.

Hi, I’m having the same issue as OP here (except im already using Execute On Server). What do you mean by “Now the server can finish by replicating the projectile actor to the clients.”? Is this an extra step that needs to be programmed? My understanding was a replicated actor spawned on the server would automatically show in the clients, but that’s not what is happening for me.

This is the most rudimentary approach.

The Projectile Actor must have class defaults: Replicates and Replicates Movement set to true.

image

This is the absolute minimalist set up.

how do you “predict” the shot on the client? I’m having the input-lag on the client and I’m not sure how to fix it.

It depends on the game and can quickly become very complicated.

You should study articles regarding Client-Prediction and Server Reconciliation first.

You need a solid understanding of how the simulation of other players work as well as how reconciliation works. If this is setup incorrectly then your predictions will most likely always fail.

1 Like

Client-side prediction is simply executing the clients input and logic immediately. Then send an RPC to the server for it to handle the networked version of it.

If the server determines you can fire it’ll do its own sim of the firing and multicast to all other sims to fire.

1 Like