Aplying damage on Multiplayer Melee Game

Hi there guys, got a few questions…
We are currently developing a melee combat system, and so far so good, it’s replicating and what not. Now we are on the part where we need to apply damage/Block with shield.

So super quick, first i need to detect a Hit and try to apply damage. I have 2 alternatives that i can think of:

  1. Put a Collider on the weapon and detect OnColliderBeginOverlap , check if the target is an enemy and try to apply damage to him

The problem that i’m reading is that if one wants to make Server Authoritative Damage, the server would need to run the animation and that’s pretty much expensive.

  1. Make a Raycast, Spherecast etc on the area i wish to damage, this is triggered by the client on an AnimNotify Event on the animation, but the Server does the Checking and Apply Damage of everyone.

This sounds good, but i would have to “hard code” the triggers for each kind of attack so i’m not sure it this is the way it’s supposed to be done on a Network Game.


The other part of the question is about Blocking Damage via shield.
For this i read that the best way to do this is use ApplyPointDamage and check the impact point and normal of the attack to see if the shield could have blocked it (i.e. back attacks are non blockable).

For this implementation i need a Raycast hit result, but the Overlaping method of detecting the attack does not give one back.
So again, point for the Raycast Method.

I’m really leaning forward the Raycast method but i’m not entirely sure. I need some feedback from guys who have done this because this is a huge compromise on future developments.

Thanks guys!

Here is what I do. I add a sphere collision component to a non-animating part of my character. I set the radius of the sphere component to match the arc of my sword attack. I then add one or more AnimNotifies to check to see if any enemies are overlapping the sphere component at the attack point(s). Make sure you only do these checks on the server side to help prevent client side cheating. This method is very cheap, but may or may not be accurate enough for your combat. Give it a try and see.

The other popular method is to add a collision sphere or cylinder to your weapon. This does require ticking animations on the server, but may provide a more accurate approach. If you do this be sure to check “Always Tick Pose and Refresh Bones” on your skeletal mesh as animations do not play on the server by default. While this method may be more expensive, it may still work depending on how many players and enemies you want to run on each server. I have tried this method but have never done extensive performance testing on it as the first method I outlined has always worked for me.

The AnimNotifies are triggered on the Client and then checked on the server via RPC? I ask because i’m under the (perhaps wrong) impression that the dedicated server doesn’t run Animations and because of that, no AnimNotifies would trigger