Networking shooting from weapon BP


I have some weapons and in their BP shoot functions… In character BP begin play im spawning weapon but i cant get it how to replicate shoot functions for client… Server works, but cant get it working for client with correct replication… (it is problem probably with ownership of that weapon or something like that)

Could someone help me please?

  • Check if your weapon blueprint is checked “Replicated”.

  • Did you try using Switch has authority?

Hello, yes i have replicated weapon bp. Switch im not using yet because i think that is not problem with spawning…
My setup is:

  1. Character begin play: spawn and attach desired weapon
  2. In character bp: weapon ref → call event spawn projectile in weapon bp… (weapon bp spawning projectiles)

I tried run on server, multicasts etc but without any results on client side… i have working projectile spawns in character bp and it works on server and clients too but for performance reasons i dont want to have many blueprints in character bp(i want to have 20+ different weapons)… problem is that client character does not own spawned weapon (probably, or client does ot have authority to command weapon to shoot) and i dont know how to make it run on clients :frowning: … i think there might be way to do it in controller bp somehow but im not sure how

You can check if your character owns the weapon by printing it.

I highly recommend you to watch and understand the epic videos on youtube about replication. Zak explains in a very nice overview how to handle what you want in replication.

There’s lot more videos on youtube about it, too.

We all know multiplayer logic is not that simple, but you need to understand RPC logic to start solving these problems.

One simple way that might solve your problem is to Use Switch has authority inside your shooting function.

Create a Custom Event: Server ShootingFunction, for instance.Set it to run on server.

Connect it, right after, to your ShootingFunction.

Inside your shooting function:

Switch has authority -> Authority -> Call Shooting Function
                     -> Remote -> Call Server ShootingFunction Event -> Call Shooting Function (client should play the effects too) 

Thanks for answer. I tried it but without results…
Here is my simplified BP:

I tried also multicast behind server call for client but client still spawning projectiles only in his view if i do server or server+multicast RPC. Base weapon is replicated so its child is too… (only server side works as expected)

epic networking video - i saw it 3x :slight_smile: + seen some youtube videos too… i spent much time (3 months, ± 300-500 hours) with learning and still googling if something i need but this stuff if new for me and cant get it why it does not work :confused: so im gonna googling more and if i find solution i will post it here.

I am working with the same type of functionality myself right now and your code seems ok.

My BP did not work for clients until I set the Projectile Actor to replicating. Even if you have the Weapon set as replicating the Projectile does not inherit that property at spawn.

Ok, you are sending, from the client to server, an event with 3 parameters, and none of them are being passed on. Probably what is happening is that when the client fires, the server client spawns a projectile.

Try removing all the parameters you’ve created inside the event and calling it to node before the switch has authority.

Something like this:


I tried but i still have same problem… Client spawn projectile, but server and other clients does not see his spawned projectile… Server works ok.

I cant believe how hard this can be… Setup which you described and i tried works well when i spawning projectiles in character BP, but if i call function from character BP to weapon BP to spawn, that does not work… i think its problem with ownership or something like that… I got second plan how it probably can work (character call → weapon calculation → send to character info and spawn on char) but i want to solve this because i cant sleep :slight_smile:

I would check:

  • Spawn and attach weapons on Server only
  • Weapon ref in Character is set to replicated.

If you spawn the weapon on both server and client without a replicated weapon ref you will use the wrong ref (the client ref) in the server event. The server has no knowledge of the client weapon ref.

THANKS a lot! :slight_smile: this was it! what a simple mistake and it took me 4 days… Thank you very much again.

So this topic is SOLVED.