Download

Melee Implementation Theory

Hello and thanks in advance for any and all assistance.

I’ve watched a few tutorials on implementing a melee system, but, as I need to truly understand the method, I’ve realized I need to start with some theory. Please keep all responses in high level theory mode.

Most systems seem to use Collision Overlap, with the damage and damage type being held by the weapon, and the recipient doing the damage calculations and health reduction.

is this the best theory, or, should the weapon and recipient pass info to a separate function that handles all of the calc and returns values?

Or, is there another way that I haven’t found yet?

Again, thanks in advance.
Jason

Actually, if I’m not mistaken, a lot of game maker and unity users use this method. This system/theory/mechanic/whatever almost seems universal. (although maybe don’t quote me on that since I don’t know much outside those three engines lol) but as far as implementing melee systems go, I honestly can’t think of anything to do that goes very far outside the enemy doing stat math after collision with the weapon of choice.

At a high level, the approach is pretty much as you have elicited.

One issue that is common is caused by the weapon positions being driven by the animation. Since which animation frames are used is framerate dependent, the swept path of the weapon does not always match the animations

One other detail - more in the weeds - has to do with determining the collision itself.
Overlap Events are triggered during the physics simulation step. Bodies that travel a high-rate of speed sometimes fail to trigger overlaps. Using sub-steps and enabling CCD can help with this (continuous collision detection).
Another alternative to this is to use sweeps or traces. These query the underlying physics world after the simulation step. They tend to be less susceptible to penetration issues.

I do recommend taking a look at Ramas plugin

Ok. So that looks amazing. I see how he overcomes the frame rate and collision issues you mentioned. And he does it by digging into the code, which i could never do. Thank you both for your replies!