Melee hit detection
Вставка
- Опубліковано 3 жов 2024
- This isn't about the networking part of melee hit detection, but:
No, hitboxes or collision hulls do not lag behind the player model
No, hit registration is never performed by the attacker's client
Yes, lag compensation and client prediction results in wacky scenarios with higher player latencies
Melee hits work by performing a line trace from the attacker's eyes. If the line trace hits nothing, then a hull trace is performed. These traces check for intersection with player bounding boxes (aka collision hulls).
The player's bounding box has a volume of 48×48×82 while standing and 48×48×62 while crouching. All classes use the same size.
The position of the player's eyes differ based on class. For Scout, it's 65 units high. For Soldier, Pyro, Demoman, and Engineer, it's 68 units high. For Heavy, Medic, Sniper, and Spy, it's 75 units high. While crouching, it's 45 units high for every class.
The line trace uses a default distance of 48 units. Swords increase this to 72 units. The Disciplinary Action multiplies this by 1.7 to 81.6 units.
The hull trace uses the same distance as the previous line trace and uses a default volume of 36×36×36 units³. The Disciplinary Action multiplies this by 1.55 to 55.8×55.8×55.8 units³ (this is why it can hit players behind the user).
While charging, melee range is increased to 128 units. However, attacking while charging cancels the charge and there's a 0.2-second delay before a melee attack is finished. So swinging after charging doesn't use the increased melee range. However, swinging before charging uses the increased melee range.
Attacks with the Engineer's wrenches perform another line+hull trace for friendly buildings. This uses a distance of 70 units and a volume of 36×36×36 units³. This is performed first, so wrenches will hit friendly buildings through players.
Attacks with the Homewrecker and Neon Annihilator perform another line+hull trace for friendly buildings that are being sapped. This still uses the same distance and volume as the melee weapon. This is performed first, so friendly buildings being sapped will be hit through players.
In Mann vs Machine, the robot team's melee attacks will completely ignore their own teammates. This is so clumps of bots wielding melee weapons can still hit RED players.
When you swing a melee weapon, the game saves a list of living enemy players that are within a distance of 120% of your melee range (from your eyes to their centre). When your melee attack misses, the game loops through this list to check if any of the saved players are still alive and in the server. If none of them are, then your attack is considered a "clean miss". If you're wielding the Boston Basher, then a clean miss means you receive self-damage and self-bleed.
Ok, the fact thar they fixed friendlies eating melee hitboxes for the MVM bots BUT NOT PLAYERS is fucking infuriating.
They did
WHAT?
They also fixed the bug with using a melee attack while charging, if MVM bots make a melee attack during a charge they get increased melee range.
The robots have won D:
It's a balance thing
@@literatemax yeah no shit, thats why it should be aplied to players. So that the game fucking works
The most informative melee hit detection guide to ever exist.
The engineer hitting building or sapper rather than enemy preferentially is incredibly important to know. Thank you for VG video.
Absolutely. Just need to remember it when taking on an engie nest.
Of course because competent engines use melee instead of shotguns lmao, this really doesnt have an use other than the demo melee charging thing
also interesting that clearing sapper has reduced range compared to normal maintenance (accelerate construction/upgrade/repair/ammo restock)
Not gonna lie, this is useful, ...very useful.
Except for the fact that melee is nye useless
@@replytothisifyouhavedumb7250 i do have dumb, and this is useful for trolldier
@@replytothisifyouhavedumb7250 i as well have dumb, and this is useful for demopannery/fishery in a way.
@@replytothisifyouhavedumb7250 demoknights? Trolldiers? Huh, SPIES?
@@replytothisifyouhavedumb7250 spies whole class is based on being sneaky, getting behind the enemy, and attempting to backstab them.
This is more broken than my dreams.
10/10 video
3:54 I imagine this one explains a lot of deaths.
I love 4:26 because it means Valve recognized the problem and then just said "fuck it".
gotta get kids to buy crates and cases with their parents' credit card baybeeeeeeeeeeee
*After nine years in development, hopefully it was worth the wait.*
*After nine years of compiling bugs, i hope it was worth the weight*
@@davisdf3064 *spoiler*
It does not. 90% of the weight are hats)))
has been*
There are some outright bugs but this design is generally quite ingenious for a very hard problem. I would not want the general designe changed. Just the bugs fixed and the animations improved. And thats where the game really falls flat. The animations do not match the implementation. Especially the swords. The design is basically a stab not a swing. Overhead swings are slightly misleading but ok. But the side swings of some swords just present a totally misleading impression of how things work. They also just don't give a good impression of the real range.
Everything makes sense now. Everywhere I looked I was told that melee is just hitscan, nobody mentioned a box sweep. This explains so much, especially why the Disciplinary Action can hit targets behind it.
Experienced the larger Hitbox before charging myself. Too bad I was on the receiving end...
it's so strange they added this extended range feature that can't actually be used for what it seems to have been designed for.
this game is a cursed mess.
When you think there's an entire gamemode made for melee... with a enclosed last point EVERYONE pile up in...
This is so interesting. It kinda explains why facestabs happen as well
And why a backstab sometimes fails as well. xd
it shouldn't explain face stabs, those are a product of lag.
backstabs are the only melee attack that comes out as soon as you click the button, facestabs are a likely result of lag
@@TheJosiahTurner
But sometimes spy is holding his knife in the janky backstab animation thing and it doesn’t backstab?
@@picklechicken8396 latency
Degroot keep here i come
Kinda wish they make it some sort of cleave that would hit everyone in the vicinity when you attack.
So it fit the animation and make it abit more realistic, then what we currently have.
That's a melee buff right there
Demoknight buff here we go!
@@Predator20357 Demoknights make a downward slash, not a side slash. It would be an upside for other classes but not for Demoknight TF2 because his swing animation is a downward slash. (excluding Demonpan and Persian Persuader Knights)
Ember I still don’t think it’s a good idea by itself, you really need to rework the melee system as not only are there usually 2 different animations for First Person View, one of them is missing from 3rd person and thus, you would get these wonky cleaves coming from downward slashes which make no sense. There’s also the fact that most weapons in the game aren’t swords and usually are axes or blunts which require you to hit the enemy full on. The only class I see that can actually use it that makes sense are DemoMan and Sniper but that’s only if you consider 1st person and not 3rd
@@Predator20357 we waited a long time for an update, if they decided to literally spend about 3+ years overhauling TF2. I gladly wait for it like most people did when TF2 was originally release.
I want a TF2 with overwatch level of polish, instead of the mess it is in right now.
No medics were hurt during this video
thanks for the informative video, i have a question though..
why do you sometimes hear your melee sound (for example a bottle) when "hitting" someone, but the hit doesn't actually register?
because it's impossible for client prediction to be perfect
@@wgetJane This makes sense for things like barely missing, but something it happens when you're looking right at somebody and even with 100 ping of lag they should still be hit
@@Sinchu9 Not according to the server.
@@Sinchu9 That never has happened to me. The reason for why it happens is because of differences between what is happening client side vs server side, and how one will always be lagging behind.
@@wgetJane Ok, let's use an example:
I'm using the caber, i charge at an enemy, swing the caber getting a crit from the charge, it makes the crit sound, there's blood formed on the enemy's face, the caber broke, my demoman did the kaboom voice line, and i heard the impact, but no damage. EVERYTHING ELSE registered correctly BUT the damage. why?
So you're saying I can stand next to an enemy building and the engie can't melee me?
Very interesting...
**interesting..**
They could still hit you if they look at a slight angle away from their buildings.
@@Banshee523 That's a risk I'm willing to take :D
@@Smidgemax that's the spirit
You are actually first man i saw who managed to explain melee stuff of TF2. I already knew almost everything, but not about "clean misses" and about sapper priority, even when i used to call myself a experienced with melee in TF2. Thank you!
"Ouch, my medigun!" - Medic TF2
You and shounic are my temporary replacement for sigsegv.
Not gonna lie, this here is the reason why me and alot other people think why melee needs to be redone from a scratch.
Maybe give it an upgrade, like able to hit multiple enemies with one swing.
@@timothylaranjo5109 No. Maybe for a new Melee Weapon for Soldier/Demo, but not for all.
Melee needs to be tied to animations. And viewmodel/playermodel relationships should be fixed, in order to show the direction the player really looks. And all melee needs to pierce through teammates.
@@TheDoomsdayzoner Maybe just for the melee weapons with a higher range? Like the eyelander, but since it's critical animation is slashing down, it could just affect one person.
that still doesn't explains why my melee hits go through enemies and end up not hitting them with me hearing the melee hit sound but not the general hit sound
When you hear the hit sound but no damage then that means the client (your computer) thought it hit but according to the sever it did not hit.
In pretty much all games there is client side prediction, it's there to make game look more smoother and synced, without it game may look choppy and de synced under bad internet connection. Can be disabled through console in TF2
stahp medic abuse
no
@@wgetJane you better stop the abuse or we will never give the heals to you.
@@YanYanicantbelievethistakenffs Medics never give heals anyway.
@@HellNutcase no with that actittude.
@@HellNutcase you expect to get healed with such an attitude ?
This is an amazing resource! Pretty well explains all the instances melee swings feel extremely jank
that moment when you see the video and start asking where did my mellee range went.
seriously, i see people getting hit while they receive 0 damage, but when i see somene trying to mellee me from distance it connects..
Yeah, same happened to me, it’s pronably ping. If you have lower ping than the opponent (for an example your is 30+ ms while the other guy’s ping is 60 ms+) then that may happen. Had it happen to me before
I've learnt a lot of this series of videos, but this especially. Thanks.
I gain brain cells watching Jane videos
I knew there were some things that were gimmicky but I didn't know there was this much
I finally know why a demo knight can kill me from across the map
Wow, the editing on this video is really top notch! Good job!
Now that I found this, I've been on a rampage as a Soldier with the Escape Plan of all weapons.
Just make it fly through everything.
More demo knights yeah?
Pyro, engineer
3:18
That explains all those weird hits...
when fighting a homewrecker pyro, just sap the dispenser to save ur own skin
Hey? What is your power?
enginner: i can hit peoples behind me looking foward
Me with the Tribalman's Shiv attacking an enemy:
WHY AREN'T YOU BLEEDING?!?!!!!
german doctor brutally assaulted by lead-poisoned man using axis-aligned bounding boxes
I haven't played TF2 in years but these videos are fascinating.
So not only does the whip have the longest range of all melee weapons but also a lot wider hit spread? Good God..
This looks like some proffesional animation for high iq students made by even higher iq proffesors
Thank you this is one of the videos that made me into a demoknight heavy main
Me: Ok time to sleep
Brain: one more video
i left tf2 like 2 years ago, and this whole channel gives me reasons to never comeback
thank you, this helps so much, i never exactly understood how melee worked exactly now its much easier to understand it
My wife keeps telling me we're broke. So I send her this video and in comparison we aren't that broke
How come melee hit detection is better with MVM Bots than it is with players?
it's because melee robots usually attack in clusters, so if they were able to hit their teammates with melee, they wouldn't be able to actually hit players since they'd just be hitting each other
That explains why the Player gets killed almost instantly when he gets surrounded by a swarm of Scout-Robots who are using Bats.
I always wondered why they never cancel each other's attacks.
@@wgetJane I'm not asking from a technical standpoint, but rather a design standpoint. I'm just frustrated that human players have to deal with their teammates eating each other's melee hits but bots don't have to.
@@wgetJane I figured why they did that for MvM, but still why not in the main game?
gonna take advantage of this to get that 0.582% advantage in my 4 second melee duel
Haven't played tf2 in years. These are oddly Entertaining to watch
wow...this guide tells me alot
Especially the boston basher
The engineer wrench melee thing was 300% more information than I ever knew before. That's why it's so damn hard to wrench a spy in your nest.
All you need to do is to switch to your shotgun and shoot the spy
All I see here is soldier flogging the poor medic.
I was worried you were gonna dismiss the extra charge range but no thank you
beautifully animated
Did I hear LAZY GAME DESIGN!?
Your pfp fits well with your comment
He explained the extender hit that solarlight came up with
Wow, such an elegant spaghetti code
I sure am glad that the shield charge melee increase doesn't really work. I chuckle imagining the same may have happened at Valve:
Programmer 1: "Huh, the shield charge melee increase doesn't actually work. I probably made an error somewhere."
Programmer 2: "Let's just leave it at that. It was a bad idea anyway, imagine what happens when we apply network latency, people will get melee'd across the map"
welcome to tf2 after 9 years in development hopefuly it was worth the wait
I wish they did so melee could be ignored by team mates in normal game as well.
Instead of having them eat every swing i give towards the enemy.
The longest range disciplinary action is my favorite, so I got Isotope whip lol
imo a melee attack should fire a bunch of tracers for the duration of the animation but only let one hit
(and make hits go thru teammates I mean wtf Valve)
Oh, that's why my market garden sounds but no hit the enemy.
This explains so much...
so that's why demo knights swings are so hard to avoid
it doesn't apply to the vast majority of demoknight swings, it's bugged to only apply if they start swinging before charging.... something that rarely happens
it explains every rage of using melee attacks
Me, a spy standing on a sapped dispenser:
The engineer, desperately trying to kill me but hitting the sapper:
ALRIGHT I GUESS I'M SUPPOSED TO SWING BEFORE CHARGING ALL THIS TIME HOWEVER MUCH SENSE THAT MAKES
So just keep swinging until you hit your target
I read this as medics hit detection
confused screeming
oooh the demo charge thingy seems interesting, will try that
This is when i realised
Melee should be hitscan.
""""Technically"""" it "is"
I once critted a scout with the disciplinary action like 5 feet away from me
Oh yeah, this is going in my "TF2 Jank" playlist
This makes sense as to why demoknights on degroot can hit a football field away when charging
So this is the reason it's hard to backstab an engineer in the dispenser nest. Multiple enemies facing random directions. So I can't hit the exact target. Also the network connection, The shit happens.
We can all agree that the crits for the Disciplinary Action are just absurdly stupid right?
Valve what kind of melee hitbox is this?!
I AM THE MELEE HITBOX
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
Thanks bro, I learned a lot.
-What about when you're near a wall?
-Sometimes I hear the 'meaty' hit when hitting a player, but I deal no dmg, what's up with that?
-No wonder my muscle-memory sucks, I play engie and and got conditioned to more range -_-
This is a very good way to visualise it, good video
What about the attacks that don't hit anything but still play a hitsound? How would that get explained? Is there a target check that happens first for the hitsound and after that a check for the damage itself oooooor?
Also very useful stuff, I like it.
the impact sound is client-predicted, so it'll sometimes be inaccurate if the server disagrees with the hit
@@wgetJane I see, thanks!
2:50 if im not mistaken, this still works for robots in mvm
so thats how i dont just fucking die sometimes using the boston basher
The Source engine is so, so bizarre. I think the only way to fix a good half of TF2's problems would be to use a different engine.
ive never been so confused
0:45 Answer to: "how did that spy killed me?"
I wonder how today's update changed the team mate interaction
Very informative video but the Boston basher segment was extremely confusing to me :0
This is why your own team eats your melee hits
Hitboxes lore
For the longest I actually thought the melee hitbox was just the size of a bullet. No wonder I always miss point blank, its cuz my teammates are next to me
Something's wrong... I can feel it...
This is so useful, until you play with 80+ ping
So that's how they hit me from a mile away
thanks jane
I've noticed some damage inconsistency with the Caber, would you be able to do a video that shows how the explosion mechanic on it works?
It does have a ramp up thing and I believe Solar light did a video with an explanation of it
Answer:
It doesn't.
i feel like teammates eating melee hitboxes is intentional, like it's so an entire team can't gang up on you and make an impenetrable wall of pain. doesn't stop it from feeling really janky though it just feels like it's accounting for that
disciplinary action hitbox is so big, it hits behind you, i have had many back duels with disciplinary action (only allowed to face away from the enemy using the disciplinary action)
*MOM'S SPAGHETTI*
no wonder why disiplinary action its one of the best melee soldier weapons that range its damn long