How to apply damage from client?

Hello.

I am trying to build a multiple player FPS game by editing the template FPS game given by Unreal Engine. But now, only server character can make damage to client character. And these are the related blueprint:

This is the projectile blueprint. Interface is used to determine whether the bullet hits another shooter. I have used Print String to find that the DealDamage function is run successfully.

79069-dealdamage.png

Here is the function DealDamage.

79070-damage.png

The value of damage is larger than 0 after CalculateDamage.

Here is the event graph of the shooter when shooter is damaged. It works only when the shooter is controlled by server.

79072-health.png

The Replication of Health is set to be RepNotify.

I have spent some days on watching some videos in YouTube. A video suggests to build a weapon blueprint and change the weapon owner of each character to the server. Is there some other ways to solve it?

The projectile is spawned by the character. Actually this part is done by the templete already so I do nothing more than saving the number buff of the character.

Who spawns the projectile though? Since the Client needs to ask the Server to spawn the projectile for him when he shoots does not really have anything to do with the weapon

Yup that is the problem then, the Client spawns the Projectile and the server has no idea it exists, as such no client can shoot the server or another client.

You need something like this:

And rehook the sound XD forgot that

Thank Mopperl! I can now damage the server character by client character now!

However, I find another problem which is not directly related to it.
I use PrintString to ensure that the HP of server character is decreasing when I keep shooting to him using client character. But the HP Bar showed above the character does not update.

The HP Bar is showed like this.

Here is the progress bar in the UI blueprint.

As it is also running correctly only on the server character, I have tried to apply the method above to solve it but it failed.

So where is the right answer?

1 Like