How to correctly replicate a projectile firing from weapon blueprint.
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.
asked Dec 21 '16 at 07:27 PM in Blueprint Scripting
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).
answered Dec 21 '16 at 07:41 PM
Follow this question
Once you sign in you will be able to subscribe for any updates here