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"

Office Holiday

Epic Games' offices will be on holiday from June 22nd to July 7th. During this period support will be limited. Our offices will reopen on Monday, July 8th. 

My projectile duplicates on my client, and the Health variable gets subtracted twice, but when shot on server the projectile works fine.

I have a projectiles that gets shot from the character, and every character has a health value. When the server fires the projectile it works fine, but when the client does the hit actor's health value gets subtracted twice (40) when it should only be subtracted with 20. I tried various multicasting and run on server variations to no luck.alt text

Product Version: UE 4.19
primaryfire.png (217.4 kB)
primaryfire2.png (138.9 kB)
more ▼

asked Aug 19 '18 at 05:22 PM in Blueprint Scripting

avatar image

6 1 2

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

2 answers: sort voted first

I managed to fix it! I set it back to how it originally was, and in the Cast and Decrease macro I just put a switch has authority between the input and the Set Health so only the Server side sets the Variable not the client as well. Thanks for the help :D

more ▼

answered Aug 19 '18 at 07:42 PM

avatar image

6 1 2

avatar image erikdubbelboer Aug 20 '18 at 01:45 AM

That doesn't sound like a proper fix to me. Your problem is that de Decreasehealth even is triggered from both the client and server projectile. You should add an "Is Server" check before you tigger that event. Not an "Has Authority" check seeing as the client has authority over it's own projectile as it was spawned there.

Another option would be to only spawn the projectile on the server and make it replicated. But this is obviously heavier as the projectile position would need to be replicated all the time.

avatar image CheesyBro Aug 20 '18 at 09:54 AM

It works both ways. But I will use your solution since it seems more performance and network friendly! Thank you! :)

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

Sounds like you are spawning the particle both on the server and client. If you want the client to trigger an event like spawning a projectile you will have to have it trigger an event on the server which in turn triggers a different multicasting event that actually does the spawning. All communication always has to go trough the server for other clients to get it. A client can't multicast to other clients.

more ▼

answered Aug 19 '18 at 05:46 PM

avatar image

361 3 4 7

avatar image CheesyBro Aug 19 '18 at 05:56 PM

You mean like this? This subtracts the health twice as well. alt text

changed1.png (200.8 kB)
avatar image erikdubbelboer Aug 19 '18 at 06:14 PM

Yes that should make the projectile spawn only once if it is triggered by a client. Now calculating the damage is something that only the server should do. So the projectile on the client is only for cosmetics. The code that calculates the damage should have an "Is Server" check before it. This is assuming your health variable is replicated.

avatar image CheesyBro Aug 19 '18 at 06:19 PM

Well the whole damage and stat setting event is set to run on server. But I can try putting an Is Server right when the even triggers.

avatar image CheesyBro Aug 19 '18 at 06:45 PM

Okay I did but the problem still exists. Also now for some reason I spawn two projectiles. One of them instantly hits me and the other one flies into the server dealing twice as much damage.

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
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