Networking: Blueprint RPC fires twice

Hello. I don’t have a background in programming so, unsurprisingly, I’m already at a loss as to what is going wrong here.

I am trying to fire a rocket at the press of LMB using ‘RequestFireWeapon’ which is set to Run on Server and is Reliable, and ‘ServerFireWeapon’ which is a Reliable Multicast.

EDIT: Although it doesn’t show in the picture, the spawn location of the projectile is correctly built into its transform.

The problem is, more often than not, the weapon is spawning two projectiles on the client side. What I find even weirder is that running through the ‘Switch Has Authority’ node after the ‘ServerFireWeapon’ event will explode one of the projectiles at the spawn location. The weapon is not firing at all on the listen server side, which is fine for now, but the issue I’m attempting to fix seems to persist on a dedicated server as well.

The projectile blueprint deals radial damage at the impact point of the hit and then calls an ‘unreliable’ Multicast to handle the cosmetic stuff.

I’ve also included below the collision settings for the relevant components, although it’s unlikely the cause of the problem. First is the projectile mesh, second is the box the origin of which is the spawn location of the projectile (doesn’t overlap the rest of the character) and third is the static mesh the projectile is supposed to hit.

I’m sorry if this might be a silly question but I didn’t find much help elsewhere. Also do point out any other mistakes you can find, it turns out I love game programming and I’m eager to learn! Thank you very much!

I Think the problem is pretty easy to solve : you should first of all remove the switches from the ServerFireWeapon and RequestFireWeapon,copy the all the code from “ServerFireWeapon” to “RequestFireWeapon”

once you got 2 events with the same code,on the Fire event(Left mouse button i suppose) put a switch has authority,or authority put ServerFireWeapon while on remote RequestFireWeapon

Hope this helps!Tell me if it works for you :slight_smile:

Thanks for the reply! Your suggestion seems to be working for the most part, except that it will still fire twice almost each subsequent time I shoot at the exact same location while standing still. The weapon not firing at all on the server side was fixed somewhere else in the blueprint, but it’ll still show clients that it fires two projectiles, one of which explodes at spawn without dealing damage. On the client side everything seems to be working as intended. Do you have any ideas as to why the issues above might occur?

Can you make a screenshot of the “Fire/Left Mouse Button” Event?The problem is probably there

You are probably right. I’ve hacked this sequence in order to prevent the player from firing more than 1 projectile every second, regardless of whether LMB is pressed multiple times or held. In its current form it doesn’t open fire if the player starts holding LMB in an unavailable position, but I will figure that later as it’s not that important right now.

To be honest, I do not fully understand it myself. I made it before creating the event for receiving damage and assumed (perhaps incorrectly) that it was working flawlessly.

EDIT: I’ve bypassed the whole sequence but those 2 problems seem to persist.

Can you also post the code after the “Fire Logic” node if possible?

I Think this problem it’s when the events are called.

Make you sure your events are set-up like this:

And the fire event something like this :

Looks like it was collision related after all! The events were set up precisely like that at some point. The problem stemmed from the fact that in the projectile blueprint the only component being destroyed was a child of the one set up for collision.

If I’ll ever get over the embarrassment, I will put this down to my incompetence. Thank you again for your help, it has been greatly appreciated!