Mele combat system

I had interesting question, about how I planned to handle mele combat in my Action RPG Example. And to be perfectly honest I had never given it much thought.

There is some core of ideas I want to keep like:

  1. Character is composed of parts. Legs, Hands, Head, Chest etc, each moveable part have it’s own collision componenet (box).
  2. So weapon at most basic level is just another collision component.
  3. In the essence I want to detect which component on character have been hit, and based on that do damage calculations (each part of character can have different armor value, or separate status like wounded etc).

I see two, ways it can be achieved. Purely based on animations. Which means that if animation with sword can hit character it will hit if not well, then not.
It have advantage of feeling right (if the animations are good), and modifying combat, by modifying animations at runtime using IK.

Second option is to simply ray trace to enemy, check for hit, and randomly select part, which was hit. Not something I’m personally fond of, since it doesn’t give any good feeling of mele combat.

How you would guys approach mele combat in game ?

For my top down aRPG, I’m doing a simplified hybrid of Zelda/DarkSouls lock on systems.
I prefer those systems cause they add more features to combat:
-1on1 fighting.
-Shield blocking.
-Directional dodging and attacks, depends on moving direction when actions pressed.
-Stamina drain.
All of that adds alot of depth and tension to combat, makes fights more rememberable than other systems I tried.
http://www.youtube.com/watch?v=9sQQDtZDC9g

it depends on how important accuracy is to your gameplay, and if there’s any meaning behind it via the control scheme.
the way I see it, if there’s no vertical and horizontal aiming (freelook with crosshair like an FPS) then all you get with locational damage is randomness for no extra reason (which can be frustrating)

as for the technical side it’s again dependant on how accurate you need it to be.
for accurate implementations, back in UDK basing such a system entirely on collision was prone to fail. the problem is that if your sword moves too fast (a sword swing can be up to a second, or as little as 0.1 seconds) then the collision will go through it entirely and the result is that many times you cannot hit the enemy. maybe it’s better in UE4 but due to the nature of this (very fast movement) I don’t expect it to be better

any decent implementation was using traces. the best I found was to run several traces along the blade, toward the direction that the blade moves (actually, using the previous frame position of the blade). something like this: http://www.youtube.com/watch?v=QXnGr-g07pI&list=PLAE1BC7C0B61B598E
it’s how I made it for my game :slight_smile:

Rather than use traces or a single piece of collision for the sword you could split a sword arc into 2-4 overlapping collision shapes that turn on and off in sequence over the course of the animation.

[EDIT] or see how far the sword has moved from the previous frame’s position to the current one and check for anything within an area of that.

I have been wondering about this subject as well. Has anyone tested the collision box,and the case where the animation is rather fast and see if a collision occurs? Seeing which method is less expensive is important as well

A collision volume should work really well IMO - the speeds that collisions are detected in PhysX for non-CCD collision is still pretty dang high, before it will miss, far higher than most animations would yield.

I’ve done this in Unity and the key is to use regular convexes (few verts) or primitives (better than convexes) to keep the speed up and allow for lots of actors in melee. It was quite robust there, in terms of catching all the hits.

I use a similar method in my Dungeon Survival project for the rat’s combat mechanics - they have a sphere trigger parented to the mouth node, and if it hits with enough force I do damage to the player (the rats jump and I put an impulse forward into them to launch them a bit).

Melee combat is high on my list of things to do and I anticipate the challenge of implementing First Person Sword Melee combat mechanic. I was considering just implementing a Fruit Ninja Slashing Slicing System with allowing the player to toggle between auto/semi-auto/manual character or weapon control. There are several ways to approach the animation control (realtime mocap/procedural). I waiting to see what developments emerge from Learn how to make a fighting game in unreal 4.

How would mele combat hit detection be any different than ranged combat hit detection with a gun? The bullet/sword/fist will still travel at x speed and do x amount of damage and can still be blocked by shields/trees/rocks/etc.

Can’t you just fire a projectile around a curve with a travel range of 1 meter?

Now there’s an idea. Well I haven’t tested it personally, I guess in theory it could be made… but remember, you’ll have to recreate it everytime a user applies a melee attack, creating / destroying objects nonstop might not be the brightest idea when you can use a cheaper and as good alternative. Plus that would work for a sword, where its basically a direct trace, but how about a more complex geometry such as an axe? One line doesn’t describe the axe accurately, by far…

Same here, but its pretty clear he doesn’t really have time to work on it.

One thing I’m not sure about is curved blades… there are no convex traces, nor convex collision boxes lol. Not only that, but with raytracing you’ll have a hard time implementing accurate detection in more complex shapes, such as axes which are a straight line, and a box on top.

Same here, but its pretty clear he doesn’t really have time to work on it.

One thing I’m not sure about is curved blades… there are no convex traces, nor convex collision boxes lol. Not only that, but with raytracing you’ll have a hard time implementing accurate detection in more complex shapes, such as axes which are a straight line, and a box on top.
[/QUOTE]

I’m just theory-crafting atm, but…

What happens when I fire a mini-gun or a shotgun?

For odd shaped melee weapons, just delay the firing of the bullet until it matches the curve of the weapon (fire multiple the bullets in a formation).

And with hit boxes; why would you ever need something more complex than one rectangle attached to each limb?

The problem with using raycasts or projectiles is that they don’t account for sweeping motions correctly, in my experience (you can easily get into a case where you have too few raycasts and it misses objects). Parenting a volume to the weapons pretty full proof from my experience. It takes a bit more setup on the art side but it’s worth it in practice.