I'm reworking the collision system in the game. I'm curious how any of ya'll have treated melee + enviro in your games.
I'm going to think through things and probably come up with something near the end of the post.
1) Dark Souls style hitbox inside of a hitbox system.
The larger hitbox checks for player collisions (and at least in my game shield collisions as well) while the smaller hitbox checks for environmental collisions. If the smaller hitbox hits the environment it cancels the attack animation and stuns the attacker. Bigger, unwieldy weapons can have small enviro-hitboxes while precise weapons like spears or rapiers can have enviro-hitboxes that are almost 1:1 with the larger hitbox.
Pro: Tweakable
Con: I don't like the idea of a heavy axe clipping the environment and having its animation canceled at any length. I guess I can solve this by not giving it any enviro-hitbox or most likely combining with some of the below.
2) Temporarily Disable Collisions
Hitting the environment disables collisions w/ the weapon for a period of time. In general smaller stabby weapons delay for a long time and bigger slashy/slammy weapons delay for less. Different environments/shields that are hit also yield different multipliers:
A guideline that will definitely be broken
........ point ... flat ... edged ...
small | 5 | 4 | 3
medium | 4 | 3 | 2
large | 3 | 2 | 1
xlarge | 2 | 1 | magically impossible 0
A similar guideline
............... multiplier ...
light shield | 1
hard shield | 3
parry shield | 5
environment | 3
A quick spreadsheet yields these frame numbers:
I colored in different breakpoints. The white squares mean you brush off the attack and continue as normal. The red means that your attack is canceled and you take that amount of stun (or maybe modify it by the threshold amount?). The orange just means it's a long time that you probably won't be able to get another hit in.
I was thinking I'd have a universal #frames to outright cancel the attack, but I'm not exactly sure. I broke the rules for weapons' framesToDelayAttack only once for the BlackBranch (small pointy mace, I pretended this is a smashy medium weapon). Some interesting points were the Knights Sword which has a neutral slash and the Halberd which has attacks that alternate between stab and slash.
Pro: Solves the problem above
Con: There will be edge cases where things delay for a weird amount of time. Also, kinda *definitely complicated*.
SO IN CONCLUSIONI think both of these systems would work well together. Combined it would look like this:
Each weapon would have two collider boxes, a float for framesToDelayAttack, and a float for delayFramesToCancelAttack. Each environment has a different weaponCollisionDelayMultiplier
If the larger collider hits the environment, nothing happens (or maybe sparks fly!).
If the larger collider hits a player, you deal damage.
If the larger collider hits a player's shield, TempDisableCollisions(framesToDelayAttack * weaponCollisionDelayMultiplier) and CheckToCancelAttack(delayFramesToCancelAttack).
If the smaller collider hits the environment, also run TempDisableCollisions(ftda) and CheckToCancelAttack(dftca * wcdm).
If the smaller collider hits a player or shield, nothing happens.
Alright, I'm going to let this thing simmer for a while. Cheers.