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.

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

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.

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.

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.

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.

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 :smiley:

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.

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