x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

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.

alt text

Any advice on how to correctly implement this would be greatly appreciated. Thanks.

Product Version: UE 4.14
Tags:
replication.png (216.5 kB)
more ▼

asked Dec 21 '16 at 07:27 PM in Blueprint Scripting

avatar image

JGock
5 1 2 2

(comments are locked)
10|2000 characters needed characters left

2 answers: sort voted first

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).

more ▼

answered Dec 21 '16 at 07:41 PM

avatar image

Dartanlla
2.6k 62 26 281

avatar image JGock Dec 21 '16 at 09:34 PM

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.

avatar image Dartanlla Dec 21 '16 at 09:40 PM

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.

avatar image JGock Dec 22 '16 at 10:39 AM

Yep that works and is exactly what I was looking for. Thanks for your help!

avatar image Pauper.Boat Apr 26 '18 at 07:26 AM

Hi , help me please I have problem about this case alt text picture everythingalt text not workalt text

1.jpg (36.8 kB)
2.jpg (36.1 kB)
3.jpg (48.8 kB)
4.jpg (45.0 kB)
5.jpg (12.8 kB)
(comments are locked)
10|2000 characters needed characters left

alt text 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.

cattura.png (131.3 kB)
more ▼

answered Jun 25 '17 at 11:19 PM

avatar image

GNUton
36 4 3

(comments are locked)
10|2000 characters needed characters left
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question