Strafe-jumping physics explained
HTML-код
- Опубликовано: 27 авг 2024
- In this video I explain what strafe jumping is, a bit about the maths behind it, and an exploration of why this is such a difficult skill to master.
Custom maps used: tr1ckhouse-beta3, xcm_tricks2
If you're interested in Quake style bunny-hopping (where forward isn't held in the air) check out my other video which explains that, as well as wall-hugging and zig-zagging: ruclips.net/video/v3zT3Z5apaM/видео.html
great! :)
Matt, can you please make a video about Quake 2 double-jump mechanic? When jumps are perfectly timed on the way up on the pile of boxes - you get vertical acceleration
19 years later and it's still worth seeing the scientific explanation.
Graph at 3min is cool.
The diminishing sweet spot is the most beautiful part of this technique in my eyes. Seeing that, and knowing this whole thing is the consequence of handling speed / deceleration in the kinda faulty way it is... it's awesome to me.
Being a technique for faster movement; the reasonably diminishing returns; the skill needed; the gratifying nature of its mastery; how it can be done anywhere you could normally walk through, makes you rethink places you'd normally just walk through, and doesnt use a special keybind or anything... It would be hard enough making something like that on purpose. So cool
Yes, exactly. I really adore when games have mechanics with this sort of natural, emergent difficulty and skillful mastery. Coincidentally, i found this video because i just downloaded unity and the first thing i wanted to try making is recreating strafe jumping for fun in a fps game project.
movement exploits tend to be cool as fuck
Now keep in mind, this amazing technique for movement is the result of a bug in Quake 1, that they decided to keep for Quake 2, 3... and pretty much any sub-sequent Quake since.
Thanks for the great explanation btw.
Excellent video! I’ve been playing for 10 years and ironically the day after I finished my grad school linear algebra final project I see this video! Loved it.
its almost surreal having something that i've internalized so much without much concious thought layed out so precisely, very interesting video!
thousands of hours of q3 and defrag and I now finally understand how SJ works. Now I just need to understand how it works in the context of "half-beat" strafe jumping.
ToxIkWaste half-beating (as described here www.trickingq3.com/Tutorials/Strafing_Tutorial.html) is just a case of alternating between forward+left and right (or forward+right and left), which allows you to change your wishdir by 135 degrees instantly, rather than the usual 90, meaning you don't have to move your mouse so much. This should only be applied once you're up to an adequate speed (ie. the dead zone is suitably wide) which is why the first one or two jumps are done normally.
Thinking of strafe jumping as "orbiting around a center point" might help. Basically, when you do the traditional forward+left/right, you're assigning a center point towards up-left/right directions. If you press left or right only, then you're assigning the center point directly your left or right. Alternatively, if you press forward only - you'll be assigning the center point directly ahead of you. This technique demonstration might also help: ruclips.net/video/gpir6ZZKmcM/видео.html
This analogy actually works much better for Quake 1/CS/Half Life/etc movement than it does for Quake 3. But in the end of the day, it's just a way to think of it rather than a valid and mathematically correct physics explanation.
@@MattsRamblings Darn the server for that link is gone, Matt. Do you have a saved version for upload? Or an alternative website for that information?
@@LukasFink1 tytytyty
@@MattsRamblings would be awesome to have half-beat visualised with curves like in this video.
(I wrote this first part before realizing the pinned comment was there.)
In many games including TF2 and I think maybe CSGO and other HL2-derived games, holding W will actually decelerate you and give you less control. This is why anybody who rocket jumps in TF2 will tell you to never use W when you don't need to. It actually makes a huge difference in the distance you get out of rocket jumping.
Thanks for the explanation of the math behind strafing in these games. I've been looking for a good one for a while because I wanted to mimic a similar thing in my own projects.
It's always fun to see the math behind something something you leanrt mechanically.
I just feel how I'm supposed to move. It's amazing such an organic way of moving can arise from this. Thank you!
Jump affects wishdir. Releasing jump while airborn is optimal.
I noticed my movement was sub-optimal and asked around. Turns out holding jump was interfering. Affects Q3 and later, does not affect Q1.
Just like crouch. I think they "lift" the original 2d wishdir into the 3d world and then the "shadow" of the lifted vector (now shorter then the original) is used for the next calculations
Thank you!
Scaling the dot product, max accel and run speed gives you control over the optimal strafe speed
Excellent video, enlightend me. Your 2 vids are honestly my favorite ever. Both topics i find so complicated that I'd rather have had a longer and slower explanation, and I think many others too.
This was an amazing explanation for how bhopping works! Thanks for the vid
strafe jumping*
Bhopping is a very different thing
First time I have seen this explained properly. ty
wow, jusr wow. fantastic info there. Been playing Quake 3 since the Dreamcast days and this is one of the best mechanics based explanations I've come across!
Brilliant video, I was trying to grasp this from a github post but I think I really needed to see it in motion to conceptualize it. Thank you, cheers!
As a 13yo cs1,6 player I thought it was just magic the computer does 😃 now I am 25yo with B.Sc in Computer Science I still think its a magic that the computer does 😃
Cool video thanks!
Excellent work. I did a big tweet thread about this a while back. you did some great visualisations of what's going on.
Holy shit I can not wrap my head around this
thanks, this helped me set up some kinda strafe jumping thing in my game project
fantastic video seriously
I always wondered what was behind strafe jumping. Won't help me to get good at it but it is still interesting. Cool video!
It seems like the currentspeed thing is just a way to prevent inconsistent max speeds.
Every frame, a constant acceleration value multiplied by wishdir is added to your velocity. That is, unless you’d overshoot runspeed in your wished direction. In that case, just set velocity in that direction to runspeed. This is the meaning of “currentspeed:” current speed in the wished direction.
Really, the reason airstrafing works is because trying to move a different direction just adds speed in that direction. It never substracts speed in your previous direction. This means that changes in direction result in a speed increase.
Excellent video man. I'm impressed.
This video is underrated as fuck
Agreed
bless the yt algorithm
And the black one too
Wonderful video. A suggestion is to add the reference speed in some your graphs, i.e. the speed without strafing.
I now understand Circle Strafing. Thanks!
I think this is the best demonstration I've seen of this phenomenon so far (the animation is especially nice). However, I believe you could explain some parts a bit more (not everyone is good at math).
I know you wanted to keep the original variable names, but "penalty" would describe the role of "currentspeed" better imho. In order to gain the biggest amount of speed, it's desirable to keep "penalty" at the minimum. Since it's equal to the dot product of the current velocity vector and "wishdir", keeping it at the minimum could be done by doing one or more of the following things:
- minimizing the length of "vel"
I don't understand most of what you wrote and I have never looked in the Q3 source code and I'm not good at math, and I almost don't understand anything in this video. However, I know why the optimal angle is changing with speed from a purely geometrical point of view.
You can't apply acceleration in a direction where your projected speed will be higher than 320 ups, that's why the deadzone increases with increased speed, because if you'd apply acceleration there you would move past 320 in that direction. The optimal angle of acceleration is the one that is as low of an angle as possible from the direction of momentum while still not touching the deadzone. This because it will give you the most forward acceleration instead of a sideways acceleration.
Explanation in picture form : imgur.com/a/caJ5u
@@yotornadoyo "You can't apply acceleration in a direction where your projected speed will be higher than 320 ups" why?
@@bunny.bunbob Because 320 UPS is the speed limit in the Quake 3 engine. When you move 320 UPS in a direction you can't apply acceleration in that direction anymore. It's coded that way. If you just run forward on the ground it will also cap at 320 UPS.
You surpass it by bunnyhopping(to eliminate ground friction) and applying acceleration in a diagonal direction that you are moving less than 320 UPS in which will create a forward moving force(and a sideways one) pushing you past 320.
@@yotornadoyo "This because it will give you the most forward acceleration instead of a sideways acceleration." the formula return vel + addspeed*wishdir indicates that there is no thing as sideways acceleration.
@@yotornadoyo in your imgur pic you also didnt explain, why the white area in the circle increases. its due to the circle growing in size.
As far as I can tell, John Carmack does this on purpose either for efficiency or because it's fun, since even Doom had a similar kind of vector stacking when combining strafe keys and running forward
Love your videos and style, Matt! Right now, I'm learning about shaders and have no idea how I would even approach making a video like this. The arrows and the grid look gorgeous and flow really well with the graph. Do you use a program, or did you make the shaders yourself? I see you put in a lot of effort into this, and it'd be very interesting to know how you did it
Despite praiseworthy visualizations this is still kinda poor explanation missing the most important points. What exactly happens, what are the types and constraints of variables, algorithm effects and why it's done this way in the first place.
The purpose of the code is to soft-cap the acceleration towards velocity vector while simultaneously allowing lateral/backwards movement regardless of actual velocity. Dot product line is exactly what fulfills that intent and inadvertently causes the exploit possibility.
The code you provided is a bad example because it's incorrect compacted oversimplification which only confuses - actual Q3A code is much clearer even if you don't really know C. The function takes as parameters wishvel vector split into wishdir (unit vector) and wishspeed (scalar value, that can vary and is not necessarily 320) components plus contextual multiplier non-important for the topic. wishvel itself is just an aiming vector altered by WASD inputs in 45° increments in horizontal viewing plane. That's where different styles of bunny-hopping come from - multiple different inputs can result in identical wishvel vector creating the same effect.
Dot-product in this specific case with one of the vectors being unit vector boils down to most basic trigonometry, without pointing that out (and displaying on the graphic) your mention of currentspeed being represented by a leg of the triangle isn't really helpful. And BTW, blue-tip-to-grey-line part is simply incorrect because wishdir is a unit vector not wishvel.
So dot-product results in a value that is guaranteed to be below VelocitySpeed and becomes lower and lower (down to negative values) the bigger the angle between the two vectors is.
If the value of currentspeed is above the cap (addspeed
@George Bush Gaming If that's to much text for you you might want to read a book or two before your brain dies completely.
Thanks for this explanation.
Could you do a second video going more into detail? I'm really interested, but as English is not my first language and the video being quite fast, I didn't get it completely. Especially how the new addspeed is calculated.
very good explanation, thanks!
Good video. One thing you don't mention though is how you accelerate slower along certain axes, because of velocity snapping (a rounding function). It plays quite a big role for harder lanes, like orange2bonus or w3spgaz_strafes blue. If you turn too much too soon by being slightly beyond the optimal angle you'll decrease your acceleration because of this snapping.
Also, Quake 1 engine games like CS have slightly different strafe jumping physics, even though the principle is the same.
that 'angle snapping' is the entire content of this video, the function which causes it is not a rounding function but instead the one shown in the video.
If that is the case, it must be because player speed isnt derived from vectors, but instead they have xspeed, yspeed and zspeed? And the vectors people use to illustrate playerspeed and all that are derived from that? Is that correct?
If that is the case, and rounding is used on playerspeed in any way (it probably is because of multiplayer) then the commenter above me is mistaken; OP is describing a separate phenomena
Very interesting by the way. Thank you.
@@assdyffv6792 the video says nothing about velocity snapping. the heat map isnt true if you consider velocity snapping. at low speeds and with suitable velocity vector, the acceleration is the same for quite a big angle range.
A very elaborate explanation, interestingly it doesn't stop here. There are other methods of "strafe jumping" mainly "inverted" and "halfbeat". With halfbeat you only need to look on one side of the direction you want to go, such as looking on the left side and alternating between "a" for strafing left and "w+d" for strafing right. This can also be performed the other way round by pressing "w+a" to strafe left and "b" to strafe right while looking on the right side of the direction you want to go. With inverted on the other hand you don't have to press "w" at all and will alternate between "a" and "d".
You can look it up on youtube, will probably find some age old "enemy territory" videos which is a game based on "return to castle wolfenstein". It features online mode which the prequel lacked and has an updated engine. Both these games use the quake engine and were kinda popular a long time ago. The trickjump aspect was rly useful in many ways and some people really jumped alot :D.
The skill cap was also really high, also getting used to it first can be kinda rough, maybe even as hard as the shooter aspect in some way.
YES THANK YOU LORD FOR GIVING ME THIS VIDEO AAAAaAAAA
I love how I learned how to perfectly strafe jump, without watching a single tutorial.
Did you use any specific Python package when you put together that neat interactive mathematical representation with the vectors?
The grid & the vectors at the beginning look like the GeoGebra canvas. Heatmap is totally matplotlib.
He may have used pygame instead of GeoGebra.
I hope he answers the question some day.
Technically,Counter-Strike and HL use GoldSource, which is modified a little '
ah thats why light is so fast it is bhopping since the beginning of our universe !
Bhopping != strafe jumping
Very interesting, thanks!
Pretty cool.
I have never found a game that allows me to strafe jump like in quake world/quake world team fortress, though. You don't need the forward key pressed in Quake 1 to gain A LOT a speed
thx, i can execute it but i never knew WHY and HOW it exactly worked.
Matt, I absolutely love this video. I'm planning on doing a video essay describing the mechanics of strafe jumping as well as describing it's various forms in different games and how it affects gameplay. Would you mind if I used your video as a reference, or used a small clip of it in my essay?
Hey Anuluxe, have you done your video essay or if not completed could you let me know where it will be etc? thanks
Harry J.D. Tate I actually have not completed or posted it yet! I’ll be posting it on my channel-don’t have a lot of content of that type currently on the channel, but you can look out for it there in the future. C:
helped me understand the racehud limits in warsow(or warfork on steam)
Holy crap, this would have been so useful like 10 years ago when I was an avid Q3 player :/
Did ID even know what they were doing creating all of this or was it unintentional? This is so advanced on a physics level
It was a mistake in the first few titles, but people loved it so they added it on purpose later on.
They actually tried to remove it from Quake 3 but people got mad about it, so they re-added it.
Finally a video actually explaining bunny hopping
This is strafe jumping. A bit different from bunny hopping
How would you calculate the optimal wishdir values given the player’s velocity? The table you showed in the video looks great, what is the formula for that?
right proper movement
Why is it that in Source games you don't hold W (and have to turn less)?
It's based on QW/Q1-kind of movement
If you hold W, the projection of vel will fall way outside of wishdir.
SimpleRockets 2, a literal game that runs with a new physics engine has bunny hopping(kind of with RCS jetpack)
I find it interesting that I’m watching this for Titanfall 2. A game that was released almost 20 years after Quake 3.
It really makes you think about how modern games are connected to older ones.
Titanfall 2 was built off a modified version of the Source Engine and the Source Engine was built off the engine Quake uses.
And then you have Quake Champions which ISN'T based on the Quake engine ironically and it is a fucking mess because of it lol
CoD4 strafe and bounce, two of the best things from the game
amazing video!
Thank you!
While it's awesome that you explained this (and I managed to replicate this in Unity)
I don't really get how this would work on slopes? I tried projecting the velocity onto the normal of the surface but all that does is severely gimp my speed on slopes and removes any gravity (even though that's added AFTER).
How would a dev nerf strafe-jumping? I didn't see how in the code the 90 degree limit was imposed. I assume to nerf strafe-jumping you would nerf the angle limit.
maybe make one about fast moving in Minecraft: placing blocks under you or jumping to hit you head on block
Physics, more important than you think.
Titanfall 2. Good video by the way
What about cpma-style strafejumping and ones from source engine, like CS:S? There you don't hold the +forward and style of moving mouse is different. As I understand, the code is almost same, so that means the difference is only in airacceleration and other variables?
CPMA consists of three different movement behaviors, depending on which movement keys you're holding. Q3-like (forward+left/right), Q1-like (left/right) and plain steering (forward/back).
Both Q1 and Q3 only have one movement behavior each. The difference between the two can be narrowed down to just two variables: 1. Air speed cap (Q1=30 \ Q3=320) and 2. Air acceleration (Q1=instant like \ Q3=gradual like).
Brilliant.
Nice
In q3 or qlive you want to move the mouse as quickly as possible from left to right, but in the counter strike games you wanna have a smooth curve between each interaction with the ground. Do you know why that is? is it because the ability to change direction in the air is much greater in cs compared to quake?
This video demonstrates the difference with just two concise variables: ruclips.net/video/MgWqaDqkBD0/видео.html -- The reason why you have more aircontrol in Q1/CS, is primarily because the air acceleration is almost instant - whereas in Q3 it's gradual. And what prevents Q1/CS movement bursting into sudden lightspeed, is the fact that it also has a much lower air speed cap. You can observe what this air speed cap is, if you start a jump with zero speed and then simply hold forward until your speed gain stagnates.
Good question,
good answer.
Awesome
Hello i wanna ask a question since i haven't found anything in google:
How would the combination of arrow keys and view angle look like? the wishdir one
i wanna know if they are all summed up to the Up/Y axis or if its in X Y and Z
this is what strafe jumping physics should be and this is what should be taught in the first place....not a bunch of losers showing how to move the mouse , that 's freaking ridiculous.
IKR
If onlyI'd known sooner that every explanation I'd heard so far was worse than useless. Shame.
Can you make a video about edge-bug?
i think for cs 1.6 that it is a bit different, if you go too quickly, it seems like you lose speed, can you show us how bunny hopping works for that game with default sv_airaccelerate parameter?
CS 1.6 was baised on HL1 engine which is almost same as quake 1 engine. In this video there is talk about quake 3 engine which is bit different
I equate strafe jumping to moving a skateboard left to right to get forward motion. Both techniques end up with acceleration.
I am tinkering with Fitzquake code and I figured how at standard running speed, gradual change in yaw direction cannot change player's actual movement direction more than about 2.5 degrees per frame. Maybe you have any idea why does it happen?
I figured it out, the problem was in bunnyhopping/strafe jumping code. Once I implemented Carmack's Quake 3 fix for bhop, an error for 100 unit radius diminished from 20 units to 3 units.
I'm trying to port Q3A movement to Unreal Gold which was a Pre-Unreal Tournament game released by Epic Mega Games (Epic Games) back in 1998, and I am just wondering if that code alone would do it?
Cool. Subbed !
what is the math behind games where you don't press forward while strafe jumping? what is different in those
None are like that. Do you mean bhopping? That has air control. Its a very very different thing
@@Wylie288 I wouldn't call airstrafing(Or "bhopping") "a very very different thing" as it is the exact same thing but with lower wishspeed and higher air acceleration.
Edit : wishspeed is called RUN_SPEED in the video
@@TarenGarond They use entirely different button presses and mouse movements. The skills are not transferable.
@@Wylie288 "what is the math behind"
@@TarenGarond Its also very different. Ive code used to implement air control into quake clones. Its much longer. On top of that, the mechanical differences mean the math also has to be a different as well.
I always wonder why there is no "surf" in quake engines compared to goldsrc even if bunny hopping (watered down) shared
Why it's not possible to stick to ramp like in ruclips.net/video/Ziso-p8l6Kk/видео.html in quake 3?
There is "surf"(Kind of) in Quake 3.
Surfing is when sliding on something with less than 0.7 vertical component of the surface-normal(Basically something with more than 45 degrees of inclination.).
When on a surface like that you aren't considered to be on ground so you have air movement and no friction.
But the air acceleration is very low(Compared to QuakeWorld and typical GoldSrc games) in Quake 3 so the "sticking to ramp power" is also very low, I'm quite sure the air acceleration is cranked up high as hell when surfing(I think the typical air-accel is 100 when surfing compared to the standard 10 in classic CS, not entirely sure though as I'm not a surfing or CS expert)!
someone tell me why accelerate is not clipped to zero? why they can be negative number??( ・・?)
no better strafe jumping than q1 and qwtf :)
In the Rocket League community this is called "wave dashing." It's not used to move more quickly than otherwise possible, but rather to accelerate very quickly and sometimes in strange directions.
wave dashing is a term originally coined from super smash brothers melee, where air dodging into the ground creates instant momentum changes. What you described is more akin to that than strafe jumping, but nevertheless, they are both awesome mechanics.
So basically quake bhop is basically like hsw style.
hsw?
Earnt yourself a sub.
I guess Quake Champions changes the last line to something like:
if (vel + wishdir * addspeed) > CHAMPION_MAX_VELOCITY
return CHAMPION_MAX_VELOCITY
else
return vel + wishdir * addspeed
!DA
They removed champion speedcaps a while ago (except for the CPMA champs for some reason)
Do you even understand vectors?
So it seems like this movement code also applies a hidden limitation on rotation speed. Player can't rotate faster than about 2.5dg per frame if he's running, and if he's walking he can rotate a little faster.
So goldsrc movement is just this but without the forward key?
Bro you made 2 videos on this
Parents: Video Games don't give any knowledge
This Video:
Was that python code?
Is quake 3 different in a way that requires you to do it half sideways rather than letting go of w?
In games with Quake 1 style movement(The "letting go of w"-style) the wishspeed(Called run_speed in this video) is way lower in air(At 30 UPS typically) than on ground but the acceleration in air is higher(You can turn and stop faster) than the Q3 air acceleration.
The optimal wishdir angle obviously is quite close to 90 degrees from where you are going(Even at moderate speed), so therefore you only use the key(Or keys if you look diagonally) that is 90 degrees from where you are heading to gain speed.
So yeah other than variable values it isn't different at all!
Following this is hard with my English skills (I thought they were good).
OK, now is there a circle strafe explanation? I need to know how to train it.
Also, how would this work in quake champions?
Just watched the video and I think I understand it now after a lot of thinking. Though circle jumping came to my mind too and I thought that it is different than what is explained above but I finally came to the conclusion it is not.
So for circle jumping there are a lot of videos and tutorials out there but I can try to explain even though I am a beginner myself.
1. Start with moving forwards til you reach the max speed (320 ups)
2. Then press forward and a strafe key at the same time (left or right / a or d)
3. In the exact moment of step 2 or slightly afterwards move your mouse in the direction of your strafe key
-> left - move mouse to the left
-> right - move mouse to the right
Though keep in mind to do a granular/smooth/continous movement and do not turn more than 45 degrees from
where you are looking at but try to keep it close to 45 degrees.
4. When you are finally looking in the direction you eventually want to move press jump.
This is normally 90 degrees from where you started because you get the most speed out of it.
5. After jumping so in the air keep moving the mouse to the side you initially started strafing and at the same time
keep forward key and the strafe key you chose pressed (left or right).
That's where you are transfering over to normal strafe jumping.
From there on after you land the next time either keep strafe jumping to the side as before or switch sides.
Also don't keep the jump key only press it before you want to jump because with keeping it pressed you will accelerate slower.
I could do a little slowmo video if you want.
Also why shouldn't it work in QC? As far as I know they used the same code for the movement as in previous titles.
Though the champions in QC have different max speed caps and different acceleration but the principle is the same except for Anarki and Sorlag. So some jumps or distances are not doable with some champions.
@@lolasdasdasdasdasdas circle jumping == strafe jumping, imagine your previous frames momentum is heading in an angular line from your point along the curve of a circle whose center is 90 degrees from the direction of that momentum. The thing is that circle is constantly getting bigger because of your acceleration, this is why you have to constantly be refacing towards the center of the circle while pressing your intended direction along the curve of the ever growing circumference of that ever growing circle.
Is wishdir a unit vector?
yes
A very new game called Satisfactory has the same thing, however the jumping is not that smooth unfortunately
Def does not have strafe jumping. I instinctively try to do that in pretty much any game I play
can you make a followup video where you explain how valve have fcked up the bunny hop mechanic in half life 2, and how it allowed backwards hopping?
Can i copy those few lines of code into an unity script and would it just work?
cod4 promod flashbacks
I fucking love Physics!
0:53
You guys ever played Titanfall 2?
bad gunplay and casual af ttk. Movement is good. Id play Titanfall 2 defrag. but as an fps its really bad
who programmed that function? lol
probably an intern..it just happens that in this case the bug became the feature