FPS - Server isn't playing the death animation when it dies

Hi,

I’m trying to create a 1v1 or 2v2 multiplayer FPS game that I can play with some friends, however, I’m new to networking in Unreal Engine.

For some reason, whenever the Client kills another client/server, the death animation is shown on that original clients POV but not on the person being killed. If the server client kills another client it works as intended - the death animation is played on both sides.

Any help would be appreciated on this one!

Have you replicated a death function? As far as I know (I’m new to UE networking too), character death must be triggered on server, processed and replicate to all clients (Multicast replication).

2 Likes

The kill event I have is set to Multicast replication. All it does is triggers an animation when health <= 0. Perhaps the health system needs to be handled by the server instead of the client? I don’t have any replication set up on that yet.

Yes, health system needs to be on server side.

So I’ve removed the health system for now just so I can test easier and the same problem still occurs. This is what I’m working with. The client can call this kill event but it only updates on the client side. If the server client calls this kill event it updates to everyone.

As far as I know, if you call Multicast replication on client, it’ll process only on client, but if you call it on server, it will process on server and all clients.
I’m not sure, but try to create a new event, which replicates on server only and calls your multicast Kill event, and make OnComponentHit event to call a new event (OnComponentHit->new event(server only)->Kill(multicast)).

If I do that the server client can still kill a normal client but it causes a different problem - if I try to kill the server the death animation doesn’t even show up on the client side anymore.

Well… Can I see how the code looks like now?

Sure

Does SR_Kill calls at client side? Try to set a breakpoint at SR_Kill node. Maybe it doesn’t work because of Branch?
Or just try to remove branch and check.

I’ve removed the branch and the problem is still the same. Adding a breakpoint doesn’t make a difference either.

It seems the SR_Kill is not being called by the client.

It means it doesn’t triggers and game doesn’t stops?

I suspect something like this. What this actor is? Is it at server side and replicates on client or client only?

When using a breakpoint on SR_Kill the game stops if the server kills a client because the server can call that event. But if the client tries to call the event nothing happens.

The actor is a first-person character with replication set to on.

You could do what is being suggested but instead of playing animation from BP,
set a variable (replicated) type bool for "bIsDead.
Access that inside your animBP and make a death state that does not loop,
and does not transition back to any other state.
At the end of your kill code, add respawn or whatever you want for “after death”


image

1 Like

I agree that this would be a better and cleaner way to code it.

But the client can still not set the servers dead boolean to true. It’s like at the moment, the client has no say at all unless it’s the server.

This is why the server code is called first and then runs the client code.
Or try running the same code on both client and server.
Then where you call “death” run both client and server one after another
and see what that results in. Not all code should be ran on just server or just client.
Sometimes it’s a matter of just testing things to see how they react.
Could be something else interfering somewhere tho.

That’s the setup I have - server code is called first

Try setting up a health system and apply damage instead of immediate killing.
If it doesn’t change health value its definitely something interfering.

Is “bulletMaster” your projectile?
I would setup the health inside characterBP and “apply damage” inside projectileBP.
Then setup a take damage system in the character like in this Screenshot

Or try this.
In your “bulletMaster”
You should be able to use that “on component hit” inside there.
Cast to your character from that and call your death inside projectile off the cast.

I originally had a health system in place and it didn’t change anything.

Yes, the BP_Bullet_Master is just a projectile with a capsule collider on it. When the player fires is generates the projectile and that’s why I’m searching if the mesh collider hits anything and then checks if it’s a projectile from BP_Bullet_Master is kills the player.

I’m wondering if theres any replication settings I’m missing? or need changing? I wouldn’t really know