Projectile only replicates when created on listen server

Hi all,

I am trying to get my spawned projectile to replicate across all clients (ie: multiplayer fps). And at one time I got it to work, but it has since broken.

I’m using the advanced car template, and have added 2 mounted guns to it:
image

In my vehicle bp, I find the vehicle’s active camera, choose the appropriate gun from that, and call my server-side fire event:


image

Inside the bullet fire function, I get the active camera again to find where to spawn the projectile, and then spawn it.

Here are my replication settings for the projectile.
image

When running in listening server mode, firing as the server will spawn the projectile, which is replicated to all clients. Firing as a client will spawn the projectile inside that client ONLY. I’m confused why it would not replicate to the other clients, considering the only time a projectile is being created is in an “Executes on server” event.

Any help that anyone could give would be awesome! I’m stuck on this one, and it’s not fun considering it was working for about 5 minutes (5 hours ago)!

Thanks,
Zack

On a listen server you are the client and the server.

Your Projectile needs to have Replicates AND Replicates Movement ticked.

On Fire pressed should check who’s calling it. Client or Server. You can use Switch has authority to do so.

Input pressed: switch has auth[remote] → Call server event [runs on server]

server event: switch has auth[Auth] → spawn the projectile etc etc.

see the following post for BP: [HELP] Multiplayer projectile replication - #13 by Rev0verDrive

Hey Rev,
Appreciate your responses man. I made some corrections based on your advice from both threads. Looks like now the server’s gun doesn’t fire, and the client gun is as it was - the firing is only seen by the client that’s firing.

When firing from the server’s view, the “Has Authority” says we have authority and Start Shooting Server is never called.

Here are my blueprints after I made the update.



image

The bullet fire bp remains unchanged. Thanks again!

Zack

Adding Fire Bullet to the authority side fixed firing from the server’s view, so puts me back at square one, but with movement replicated now :ballot_box_with_check:
image

You shouldn’t need all the casting.

I’m assuming the Gun is an Actor class attached to the Pawn (character). And said actor has all the firing logic. So your “Start Shooting Server” event should be in the character class. This event should call an event in the weapon class (fire bullet server). Doing so you don’t need to cast, nor pass anything to the rpc event.

Pressed: Switch has Authority [Remote] → Start Shooting Server

Start Shooting Server: Switch has Authority[Auth] → Get Gun Component Ref → Fire Bullet

Released: Switch has Authority [Remote] → Stop Shooting Server

Stop Shooting Server: Switch has Authority[Auth] → Get Gun Component Ref → Stop firing Bullet

There’s Only ONE RPC Server event per action. Start and Stop.

If you need a video on me building this from scratch and showing replication I will.

Looks like the Start Shooting Server event being inside the gun was the issue. I moved the initial server call from the gun class to the pawn class, and it’s now replicating!
It’s not perfect, but you got me unstuck. Thank you!