Problem Replicate Firing

Hello! I have a problem and no matter how much I search, I can’t find a solution.

I will give context so that it can be understood better: I have a Blueprint of type character that is the character, I have a multicast event which contains some branches and at the end it has a “Blueprint Interface” to connect with the weapon blueprint

Then I call that event “Trigger client” from a server event like “Run on server”

and then in each input I call that event

At the end of all this it executes the blueprint interface that passes it to the weapon blueprint

My big problem is that when I run this in multiplayer, 2 windows appear, the editor one and another separate one.

In the editor’s gun it shoots correctly, but in the client’s gun when he shoots, his gun doesn’t fire and the server’s gun shoots, I’ll explain again in case you don’t understand:

Player 1: Server
Player 2: Client

When shooting in player 1 everything is fine, when shooting in player 2 it doesn’t fire but you can see that player 1’s gun fires.

I have searched thousands of places and I can’t find a solution, can you help me?

Client presses Fire → Fire a Local only shot → RPC server to Fire
Server Fire → Same exact firing logic as client → Multicast to Sims
Multicast to Sims (Data server used to fire its shot) → Sims Fire

That’s the basic flow. If you’re using projectiles there’s a more complex setup. You don’t replicate projectiles. Each proxy needs to either pool or spawn a local only projectile. Whereas the servers is the only that does damage on hit.

I didn’t understand it :frowning:

I still can’t solve it, I did it as you told me, although it is not clear to me about the server value, I have been trying to solve this for 6 days and it has stopped me.

You doing hit scan (line trace) or projectiles?

Add a line trace and it looks upside down, I imagine it’s due to the “socket” of the weapon, however, I am suspecting the blueprint of the weapon, or the spawn actor because the shooting animation does reproduce it perfectly in the client, I also think that I am missing an “owner” that indicates who is the owner of the weapon that is being fired, although I tried that and it doesn’t work either, or I did it wrong.

in the main character I put a print string

and he throws this at me… will it have any meaning? It’s like they both create the weapon, but then it is deleted.

Weapon has to be spawned by the server for all players. Weapon has to be set to Replicate.

Sounds like you are doing Listen server instead of dedicated.

I think I left out that the weapon is built with PrimaryDataAsset → Data asset, and a blueprint for the logic.

When you instantiate the weapon on the map, only that weapon fires, so I realized that it doesn’t matter if the replication is done right, the first weapon instantiated will always be the one that fires.

Do you know any way to tell the gun that it can only fire from the player?

Conditional flow logic…

Get local Role, is server, is locally controlled etc