Here is what looks wrong to me. The Fire event inside the weapon BP should say “Executes On Server” not “Executes on All”.
I would take the code from your weapon BP and move it into your Character BP. Then use Run on Server with Reliable checked to setup the “Fire” RPC call. If you do that it should work.
What I have found in the past is that actors do not replicate like the Character class does. The reason for this is that RPC calls are only executed on Actors owned by the Player Controller (such as the Character).
I’ve been trying to get my head around blueprint replication and seem to have hit a wall. My current setup has 2 characters spawn in, one as the server and one as the client. If the client was to fire their weapon (Actor WeaponBP which is spawned in and attached to the player on game start) the projectile spawned would only show on their own screen, not the server. The server firing a weapon and spawning a projectile would be correctly displayed on both side though. It is only when the client shoots his gun that this does not work.
All actors are set to replicate with the same settings, and the function called “Fire” (inside WeaponBP) is set to “Multicast”. A check is also done to make sure the action is performed on the server only using the “Switch has Authority” node. Below is a visual representation of my blueprints.
Any advice on how to correctly implement this would be greatly appreciated.
Thanks! That does indeed work, but is there no way to achieve the same result while keeping all of the weapon fire functionality inside the weapon blueprint? Taking all the information required for a decent weapon firing system (like fire rate, magazine size, etc) from the weapon and passing it into the character wouldn’t be too hard, but it just seems cleaner to keep it all together.
You can still keep the functionality in the weapon, you just have to call that functionality from the Fire event in the Character.
What I would do is create a base weapon class/BP that contains the Fire method you want to call. Have the Fire event in the character call the Fire method in the weapon. Then for each new type of weapon override your weapon base class/BP and add weapon specific functionality.
Yep that works and is exactly what I was looking for. Thanks for your help!
Here is the way I replicate the fire action. The Fire routine is in the weapon actor BP, but the replication part is in the character BP.
Hi , help me please I have problem about this case
if you want, i can provide even simpler
You can set bReplicates in weapon BP if you want