@@danolantern6030lol games usually arent designed around speedruns but devs may choose to leave in some bugs runners use. Like ocarina of time 3d they left in super slides but fixed but the buggy crouch poke. now modern zelda games they fix all the fun bugs before any of the game breaking stuff lol
That's not true. The actual reason for that is that all directions of movement max out at Speed 40. However, a glitch that allows you to move and strafe in the same direction simultaneously can give you a speed of value of SR50 or SL50 (Strafe Right 50 or Strafe Left 50) It's only faster than running on long stretches where you can do it for long enough. That's why they'll usually just run forward or to the direction of the next objective if they're in a small room.
The fact that this is as common as it is is kinda mindblowing to me. This happens in Minecraft, which especially is a big deal for bridging quickly (in Java). It just sounds like such a silly mistake though
One reason it's so common is because, like, just normalizing diagonal movement in a game like this would knock the pixel art character out of alignment with the pixel grid. Minecraft has no excuse tho lol
@@varglbargl Yeah, if you have a game where the character moves at least a pixel at a time, then you would need around 10 pixels for it to move 7 diagonally (for it to be close to the ratio). You could of course like make it walk half the speed, so you can have a character that moves two pixels in one direction move one in both (the diagonal can be divided in two axis movements), but then diagonal movement becomes so slow it rarely would make sense to use it (it does make some sense though because it would take the same time to walk diagonally and to walk only in the 2 directions that correspond to it)
When you throw a football or any ball. Although you may not realize it, you are calculating the force needed to throw the objects in an arc which is the basis of the theorem
I mean I get mad in general when people ask/say stuff like this regardless of any specific math-topic. Yeah you MAY NOT need it, but you probably don't know your future profession when you are still in school, so it's better to learn it so you are not an idiot when you want to have an engineering or science degree. And even here in videogame development. Computer Science is literally a branch of math and we are surrounded by computers these days
Sometimes its actually better to leave this in as a "bug but actually feature" since it can help make walking less monotonous for certain players, as strafing can keep things feeling active.
dude you started learning algebra at 1st grade. trying to find out the answer to 1+1=x is algebra. I'm pretty sure you've used it in a lot of ways in your life now.
The problem with this for pixel games is that you can't move half a pixel. If you try to code that in, you move in a jittery way, depending on the speed. To fix that, you would either have to do some complicated code that take frames into account, or you just super size everything by 2-4x
In many game engines, especially those that can be used for 3D games, you can actually move weird fractions of a pixel because they represent all positions in floating point. But if I'm trying to make a game look retro, I might use integers, either whole pixels or half or quarter pixels (the latter are useful if I want some things to move faster than others). And probably keep diagonal movement faster than rooklike movement because if players notice it and take advantage of it, well, that feels better than artificially slowing them down. (Not necessarily making diagonal movement 1.41 times faster, but perhaps 1.5 since that's easier to do fixed-point maths with.)
@@michawhite7613 I'm talking about numbers in-between whole numbers. For example, if your horizontal and vertical speed is 6 pixels, then by calculation your diagonal speed is about 8.5 pixels. The game engine does not let you move sub pixel, so you're relocated at the coordinates which may cause your character to move in a jittery way.
It's incredible that they didn't fix this though. N64 was already an advanced time compared to the NES / snes era, and this diagonal problem is a well known one
Pretty surprising to see this issue pop up even in more recent games. There is this indie Super Monkey Ball tribute game called Paperball which does the exact same thing, no vector normalization, so diagonal movements are simply faster. I know it's an indie game, but otherwise pretty well made, and it's so recent...
A fun side effect of having all of those different and weird control schemes is that some of them had a genuine advantage over the others, because of funky programming. :P
@@vulkanosaureMy guess is it's a video game where the player is bounded to the square of the map Like, you can't just move quite a bit, you have to go from a square to another It's not possible to fix diagonal walk in those game, it would make the player stand between the squares, which would break the game
After 12 years of school my dude finally answered the most asked question in math class. When am I ever going to use this? Pythagorean theorem, vectors, square roots. I think some of us owe our math teachers an apology 😅
@Seppo could you imagine if, when your math teacher was asked "when will I use this", their response was "well do you like video-games"? I would've retained wayyy more math.
I find it a little bit astonishing how you can be into game development and not apreciate the insane amounts of math needed. OpenGL Rendering requires a ton of Matrices and Projection Math, a maybe quaternions. Physics Simulations require calculus and, well, physics. Everything is expresed with vectors. Meaning that you need to be VERY confortable with normalization, vector arithmetics, and maybe the dot and cross product. Strategy games requiere some knowledge of Dynamic Systems. RPGs and competitivr shooters require knowledge of calculus for balancing the attribute of enemies, weapons and characters by finding minima and maxima of functions. And i could go on for s long while I hope i don't discourage you from GameDev tho. Quite the opposite, i ecourage you dig deeper into the math. You might find it quite enjoyable when you explore the possibilities
@@shad-fanatic Lol, people deleting their comment just to make you look a bit crazy. It's sort of like when a tonne of people upvote a comment... then the person changes the comment to something absurd, and you're like "why are so many people upvoting such a stupid comment?"
If you have to use integer pixels, have moving diagonally by 2 pixels in each direction take three frames. This means you're moving sqrt(8)/3 pixels per frame, which is about 0.94, which is close enough to make the speed difference far less noticeable.
In this type of game(with 8 direction movement) it is easier to just create a new constant that is approximately equal to sqrt2 and use it for diagonals. This reduces the need of constantly normalising direction vector, which implies square root every moving frame.
For anyone wondering how the code works local vec = vector(dirX, dirY):normalized() * player.speed player:setLinearVelocity(vec.x, vec.y) DirX and DirY are either 1, 0 or -1 depending on which direction he goes The code is grabbed from his Zelda game
@@pyrytheburger3869 the reason for that was probably that he barely fit in one minute lenght of the video (which is a short). I might be wrong, but I guess that if he added explanation it would cross the "limit". Neverthless, quite bad that he didn't pin the answer (the one above) or write his own. Btw, I know this was 9 months ago xD
It also applies to movements in 3 dimensions in 3D games. If you move forward 1 unit, to the right 1 unit, and up 1 unit, the total magnitude of your movement will be equal to the square root of 3 (about 1.73), as compared to the 2D diagonal movement example here , which is the square root of 2 (about 1.41). This even applies to movements in theoretical 4D dimensions and beyond.
In 3D games, up velocity is usually done separately, bc of gravity, and u can’t add continuous velocity when jumping, so the jump strength is balanced around the jump height. Ofc space games are different tho
Coming from an avid OW2 nerd, you just helped me understand faster flying character's movement tech. Specifially, Echo's mainmovement ability lets her fly vertically while holding the a diagonal movement combination. This is just better to do as Echo when flying (which is what her thing is.) Now, mathematically, I will, be the Echo Diff, if not in frags; then at least in quicker fly speed velocity.
@@10_days_till_xmas Yeah typically character movement in 3D videogames would not be utilizing all 3 dimensions in the same way, so it is more like 2D movement in that regard. But it still applies to other use-cases outside of the main character's movements, such as with flying enemies, particles, and perhaps scenery.
@@10_days_till_xmas This made me think of flying around in Descent bumping into walls. It was the first game I played with fully 3D movement (up, down, rotation, rolling, etc.) and it got really confusing at times!
quick note: normalising the vector will also INCREASE its value to 1 if you try to only move slightly. You want to normalise _the direction_ and apply movement speed separately - you might run into unexpected behaviours otherwise
i am not kidding i was JUST listening to Colony 9 (Night) from Xenoblade DE, then i paused it to watch this video and THE SAME SONG STARTED PLAYING??? i thought my PC was acting up but nope, we live in a simulation
Its simple videos like this (and the graphics used) that motivate me again to do game development. I have been super interested in making games but always burn out because I dont have the artistic skills to make the graphics 😢
I love how you explain these concepts generally without specifying a game engine this help different game engine users to apply these cocepts according to game engine that they're using
Normalizing the vector is good for 3D games but when I developed my game, the diagonals felt slower despite it moving the same speed. So I made it 1.2x faster for diagonals on purpose and no one noticed in testing because it felt more normal than actually normalizing.
Thats probobly becouse the screen will move slower when you are still holding the same key since you cant move camera around to abuse fastness of it like in 3D games id say its a good idea to keep it fast like you did
little cheats like this are often necessary for things to feel good. it's particularly useful when running up slopes - players rarely want the physics to be realistic in that case, since it only slows them down
The thing about normalizing is that while you move at the same speed in the diagonal direction, you lose speed in the vertical or horizontal direction which discourages you to have a little fun when moving from point A to point B
@@Muho_is_meyeah I noticed this in Stardew Valley, the camera moves a lot slower when walking diagonally and it feels painful so I just avoid walking diagonally even though I know it’s the same speed
Old RPG games like that would just let you move faster diagonally. It is actually pretty nice for gameplay, it feels good being able to move faster diagonally.
please make more of these short videos... these short videos make those tutorial easily understandable.... maybe you can compile them someday for a small price
fun fact: controller sticks have this kind of "normalizing" built in. since it can only rotate in a circle, it can only read X and Y axis inputs within that circle, meaning all edges of the stick are a 1 input, in some combination of X and Y
This is always something that you could do, but it's not always something that you should do. For example, I know undertale doesn't do this, as it doesn't really have a reason to. If you were to do this to a game like undertale, you would be slowing down the movement for no good reason. Now if you had a game where your speed not being consistent would upset the balance of the game, like a game where you spend a lot of time running away from enemies, this would be a pretty good change.
That’s awesome. I am a programmer and I’ve made this kind of game before. I had wondered in the past why this happen. I always assumed it was 2x speed but the fact that it’s 1.4 makes complete sense and it’s really interesting.
I actually kind of prefer the faster diagonal speed. I think having things that make big fans of the game faster or stronger without specifically adding in more equipment for them to grind to is underated. Being able to go 40% faster by figuring this out is so much more fun for me as a player than logging 20 hours for voots that do the same. And it being available from the start of the game just means that any returning player will be rewarded with tips and tricks from their intial play through. It will also help cut the time to retrace steps and travel times
This is comparable to the decimal error oversight in epicness where you got a useless or a broken mechanic because you were missing or having a 0 too much
i wrote a little multiplayer game as a kid where i noticed this, overcomplicated the math to fix it, and when me and my friends playtested it we decided it was more fun to keep fast the diagonal movement in
This "bug" existed in a lot of older games. I remember in Perfect Dark on the N64, there were cheats you could unlock by beating levels in a certain time on a specific difficulty. By using diagonal strafing, you could speed your character up and beat the level faster. This is also an issue in any game with tile based movement, such as a lot of strategy games that use square grids. It's one of the reasons why a lot of people prefer hex grids, since there is no diagonal movement on a hex grid.
a general version of the solution where the angle of movement can be any angle (not only multiple of 45°) would be to use trigonometry ; vx = cos(angle) * velocity vy = sin(angle) * velocity then use vx and vy to increment your character's position. that's what you would need if your input system allow you to go in any direction (ex following your mouse)
@@arctic8137 aight i wrote this real quick in GML, it should get the job done - player object create: spd = 6 diag_mult = 1 - player object step: xmove = (keyboard_check(ord("D")) - keyboard_check(ord("A"))) ymove = (keyboard_check(ord("S")) - keyboard_check(ord("W"))) xspd = spd * xmove yspd = spd * ymove diag_mult = 1 if !(xmove = 0) && !(ymove = 0) { diag_mult = .6 } x = x + (xspd * diag_mult) y = y + (yspd * diag_mult)
This is probably a late reply but oh well. To "normalise" like it says in the video, you divide the X and Y by the distance moved. So, If you are moving orthogonally, or vertically, divide the X and Y by 1. If you are moving diagonally, divide the X and Y by 1.4. The key thing is to slow yourself down if you are going diagonal. To implement this for any direction, you can do something like: (set initial movement) x = 2 y = 3 (work out length of move) length = √(x * x + y * y) (normalise movement by dividing by length) x / length y / length (movement should now be exactly 1 unit in any direction) (multiply by speed or whatever for final value). The other comment replied with multiplication probably because that's quicker for a computer to do iirc.
@@dephoro Sure, I was just explaining how to "normalise" a vector, so I kept the example as simple as possible. Normally my implementation doesn't use any branches at all. Normally it's just something like: - Get initial vector from input. - Normalise the vector (should just be a function called Normalise) Literally two function calls, you would be hard pressed to find a solution cleaner than that. The Normalise function is also quite a common operation that has been optimised to death(atleast with improvements to sqrt). You can modify it further if you need extra features, but I don't think it gets much simpler or faster than just input.Normalise(). If your engine doesn't have a native Normalise(), you can implement it yourself using pythagoras (it's a single line for the equation, and doesn't involve any branches). Normalise just takes a vector (an X and Y value) and outputs circular values for them, exactly as you describe(It outputs on a unit circle though). What is the difference between your solution and just normalise?
That remembers me the fact that some old games forgot it in some situations like in hitman bloodmoney where you're faster when dragging a body in diagonal.
speedrunners hate this one programming technique
I was thinkin the same thing lol
Goldeneye players too
we need a list of 3d games, that fail to normalize some movement vectors.
Speedrunners when not every single little exploit is kept in for them and not every little aspect of a game is designed around them
@@danolantern6030lol games usually arent designed around speedruns but devs may choose to leave in some bugs runners use. Like ocarina of time 3d they left in super slides but fixed but the buggy crouch poke. now modern zelda games they fix all the fun bugs before any of the game breaking stuff lol
This is why they move diagonally in original Doom speedruns
Doesn't count for the fact that you run SIGNIFICANTLY faster by running diagonal along a wall in Doom/Doom 2. That's just a straight up bug.
That's not true. The actual reason for that is that all directions of movement max out at Speed 40. However, a glitch that allows you to move and strafe in the same direction simultaneously can give you a speed of value of SR50 or SL50 (Strafe Right 50 or Strafe Left 50) It's only faster than running on long stretches where you can do it for long enough. That's why they'll usually just run forward or to the direction of the next objective if they're in a small room.
And Goldeneye
@@platinumfactoryes, a good example of the movement shown in this video would be diablo 1.
@@platinumfactoryea you can run along a wall and run faster…
Running in zig-zags never made more sense
The fact that this is as common as it is is kinda mindblowing to me. This happens in Minecraft, which especially is a big deal for bridging quickly (in Java). It just sounds like such a silly mistake though
One reason it's so common is because, like, just normalizing diagonal movement in a game like this would knock the pixel art character out of alignment with the pixel grid. Minecraft has no excuse tho lol
i dont think godbridging exists in topdown pixel games though
@@varglbargl Yeah, if you have a game where the character moves at least a pixel at a time, then you would need around 10 pixels for it to move 7 diagonally (for it to be close to the ratio). You could of course like make it walk half the speed, so you can have a character that moves two pixels in one direction move one in both (the diagonal can be divided in two axis movements), but then diagonal movement becomes so slow it rarely would make sense to use it (it does make some sense though because it would take the same time to walk diagonally and to walk only in the 2 directions that correspond to it)
@@raven-aanother solution: make the character's minimal speed X pixels/frame and round normalized diagonal velocity to nearest integer.
it's extra math, normalizing the vector isn't as simple as dividing by a specific factor if the game allows multiple movement speeds
Note to self: When escaping from danger run diagonally. Those straight line runners will have a hell of a time trying to catch up.
Remember, you don’t need to outrun the monster. Just outrun your friends!
lmao🤣🤣
😂😂
@@meteylmaz4366 note to self, run at an angle which you can run directly to your friend to clothesline them, whilst moving diagonally.
The World is not Enough on N64 in a nutshell
This is the first time I've ever understood the relation between the game math and the result. Thank you so much.
Same!
I just clicky cause I wanty. Sides, could use polar coordinates instead of this Kardashian coordinates and save some computing power 🤣
@@hikari1690That would work, but wouldn't save any computing power.
Big brain
@@hikari1690Cartesian*. Kardashian coordinates would be used to measure amount of plastic in a bimbo
"When will we ever use Pythagoras in real life?"
Clarification: this comment is mocking people who think this
Pythagorian theorem is one of my most used formulas. Trigonometry is so useful.
Pythagoras is the most used theorem outside of school and direct mathematics istg
When you throw a football or any ball. Although you may not realize it, you are calculating the force needed to throw the objects in an arc which is the basis of the theorem
I mean I get mad in general when people ask/say stuff like this regardless of any specific math-topic. Yeah you MAY NOT need it, but you probably don't know your future profession when you are still in school, so it's better to learn it so you are not an idiot when you want to have an engineering or science degree.
And even here in videogame development. Computer Science is literally a branch of math and we are surrounded by computers these days
He explained it explicitly trying to fit it to use that math technique.
Still useless lol.
Sometimes its actually better to leave this in as a "bug but actually feature" since it can help make walking less monotonous for certain players, as strafing can keep things feeling active.
This is such an important thing. So many devs lost this mindset.
I tried normalizing movement for something. It really didn't feel right. Even if you're going the same speed, it feels slower
@@mchlkpngBecause you basically are. You're not going forwards as fast, nor are you moving to the side as fast.
@@anonymousapproximation8549 true
Nah its not better lol
"When are we ever going to need to use the Pythagoras theorem?"
It"s also literally one of the most commonly used formulas in real life to measure distances in all kinds of situations.
@@19Szabolcs91Measuring stuff uses trig more than pythagoras. It comes in handy for setting up perpendiculars though.
“You won’t, but the smarter kids will.”
@@19Szabolcs91yea like i use it every day, i work at a photo shop and im definitely not gonna bust out a measure for a frame i know the sides of
My dad in school: "Fuck this algebra and geometry shit I'll never use it"
My dad at work: is a carpenter
Love how algebra actually becomes so helpful when you get into programming
Its kinda more linear geometrics then algebra bc the formula is about a triangle and its sides but nevermind
dude you started learning algebra at 1st grade. trying to find out the answer to 1+1=x is algebra. I'm pretty sure you've used it in a lot of ways in your life now.
Welcome to engineering - where we actually use the maths we were taught in school
I laugh when I think back to all the kids who thought that math was useless because they just wanted to become programmers
especially when you take linear algebra and it’s basically fundamental to computing graphics and games
The problem with this for pixel games is that you can't move half a pixel. If you try to code that in, you move in a jittery way, depending on the speed.
To fix that, you would either have to do some complicated code that take frames into account, or you just super size everything by 2-4x
In many game engines, especially those that can be used for 3D games, you can actually move weird fractions of a pixel because they represent all positions in floating point. But if I'm trying to make a game look retro, I might use integers, either whole pixels or half or quarter pixels (the latter are useful if I want some things to move faster than others). And probably keep diagonal movement faster than rooklike movement because if players notice it and take advantage of it, well, that feels better than artificially slowing them down. (Not necessarily making diagonal movement 1.41 times faster, but perhaps 1.5 since that's easier to do fixed-point maths with.)
I think usually characters move more than one pixel per frame.
@@michawhite7613 I'm talking about numbers in-between whole numbers.
For example, if your horizontal and vertical speed is 6 pixels, then by calculation your diagonal speed is about 8.5 pixels. The game engine does not let you move sub pixel, so you're relocated at the coordinates which may cause your character to move in a jittery way.
@@Pie_Mastah My intuition is that the difference between 8 pixels and 9 pixels isn't noticeable, but I could be wrong.
@@michawhite7613 only noticeable when in a pixel art style, when 8-9 pixels is like half the size of the player
Pythagorean Theorem, my beloved.
The first time I noticed this was back in the N64 days, playing Goldeneye 007. Diagonal movement was a legit tactic I used to speedrun missions.
It's incredible that they didn't fix this though. N64 was already an advanced time compared to the NES / snes era, and this diagonal problem is a well known one
Looking down to run the game at a constant 60fps is another speedrun strat for that game.
Pretty surprising to see this issue pop up even in more recent games. There is this indie Super Monkey Ball tribute game called Paperball which does the exact same thing, no vector normalization, so diagonal movements are simply faster. I know it's an indie game, but otherwise pretty well made, and it's so recent...
A fun side effect of having all of those different and weird control schemes is that some of them had a genuine advantage over the others, because of funky programming. :P
@@vulkanosaureMy guess is it's a video game where the player is bounded to the square of the map
Like, you can't just move quite a bit, you have to go from a square to another
It's not possible to fix diagonal walk in those game, it would make the player stand between the squares, which would break the game
After 12 years of school my dude finally answered the most asked question in math class. When am I ever going to use this? Pythagorean theorem, vectors, square roots. I think some of us owe our math teachers an apology 😅
Go for engineering studies and oh boy you're going to need them a lot :D
@Seppo could you imagine if, when your math teacher was asked "when will I use this", their response was "well do you like video-games"?
I would've retained wayyy more math.
I find it a little bit astonishing how you can be into game development and not apreciate the insane amounts of math needed. OpenGL Rendering requires a ton of Matrices and Projection Math, a maybe quaternions. Physics Simulations require calculus and, well, physics. Everything is expresed with vectors. Meaning that you need to be VERY confortable with normalization, vector arithmetics, and maybe the dot and cross product. Strategy games requiere some knowledge of Dynamic Systems. RPGs and competitivr shooters require knowledge of calculus for balancing the attribute of enemies, weapons and characters by finding minima and maxima of functions. And i could go on for s long while
I hope i don't discourage you from GameDev tho. Quite the opposite, i ecourage you dig deeper into the math. You might find it quite enjoyable when you explore the possibilities
For everyday life? Probably not, but math is the heart engineering, science and coding imo
I must say out of everything,
Pythagorean theorem is the most used formula ever
I never realized why diagonal movement was so uncanny, this was so helpful
Bro the Xenoblade music! Mad respect.
As the artist of an indie team, I really want that guy to have diagonal animations
👍
@@shad-fanaticWhy’d you reply to your one comment?
Someone else commented before, but I think they deleted it
@@shad-fanatic Lol, people deleting their comment just to make you look a bit crazy.
It's sort of like when a tonne of people upvote a comment... then the person changes the comment to something absurd, and you're like "why are so many people upvoting such a stupid comment?"
yes
I could swear I heard Colony 9 in the background. I love you.
Yeah!!! Xenoblade OST fans! Escoecially the night time theme!!!
Yess! Colony 9 night music is one of my favorite video game music pieces of all time.
I love this song!!
@@gavinli1368I recognized it right away bc it’s one of like 5 songs from the game I use to fall asleep lmao
I immediately knew it was a xenoblade song I just didn’t know which one, thank you
If you have to use integer pixels, have moving diagonally by 2 pixels in each direction take three frames. This means you're moving sqrt(8)/3 pixels per frame, which is about 0.94, which is close enough to make the speed difference far less noticeable.
In this type of game(with 8 direction movement) it is easier to just create a new constant that is approximately equal to sqrt2 and use it for diagonals. This reduces the need of constantly normalising direction vector, which implies square root every moving frame.
divide the speed by sqrt2 and put it in both x and y of movement vector
Speedrunners want to know your location
For anyone wondering how the code works
local vec = vector(dirX, dirY):normalized() * player.speed
player:setLinearVelocity(vec.x, vec.y)
DirX and DirY are either 1, 0 or -1 depending on which direction he goes
The code is grabbed from his Zelda game
Thanks. It's a shame the uploader didn't give the actual answer and just "blah blah got it? ok bye" to us.
where shoul i copy it? in fuction load or update
@@alessioturco953 update probably
i would recommend learning how normalization works with math.
@@pyrytheburger3869 the reason for that was probably that he barely fit in one minute lenght of the video (which is a short). I might be wrong, but I guess that if he added explanation it would cross the "limit". Neverthless, quite bad that he didn't pin the answer (the one above) or write his own.
Btw, I know this was 9 months ago xD
I felt so smart when I realized and instantly knew how to fix this while I was learning game development.
Miss those fun yet depressing times.
Such an elegant explanation
I'm working on a top down adventure game and this actually helped fix my diagonal movenment. Thanks!
Which engine are you using?
I can't believe I fell asleep during maths classes..... Damn it!
Ik I’m late at answering but, I did too 😅
Math is very dry stuff most of the time, and very exousting to take attention to. ( english is not my primar language, sorry for errors)
nah its not ur fault, they make it as boring as one could imagine
im happy that now (im at the very end of gen z) at least in australia them highschool teachers make maths interesting if not sufferable
@@zaplershorts7783 were u still sleeping
I'm so used to the faster diagonal movement that normalizing it makes it feel super slow now
I love how you used two different algebra topics, even one from linear algebra, which is what I’m learning right now
I will refer to this video every time I make a top down game. Thanks so much! Also appreciate the Xenoblade music.
no wonder my game character felt a little fast when moving diagonally thank you so much I forgot about this lol
Undertale is a great representation of the fast diagonal movement
As a very new person to video game programming, im feling myself that i figured this out and fixed it in my first project 😊
It also applies to movements in 3 dimensions in 3D games.
If you move forward 1 unit, to the right 1 unit, and up 1 unit, the total magnitude of your movement will be equal to the square root of 3 (about 1.73), as compared to the 2D diagonal movement example here , which is the square root of 2 (about 1.41).
This even applies to movements in theoretical 4D dimensions and beyond.
In 3D games, up velocity is usually done separately, bc of gravity, and u can’t add continuous velocity when jumping, so the jump strength is balanced around the jump height. Ofc space games are different tho
Coming from an avid OW2 nerd, you just helped me understand faster flying character's movement tech. Specifially, Echo's mainmovement ability lets her fly vertically while holding the a diagonal movement combination. This is just better to do as Echo when flying (which is what her thing is.)
Now, mathematically, I will, be the Echo Diff, if not in frags; then at least in quicker fly speed velocity.
@@10_days_till_xmas Yeah typically character movement in 3D videogames would not be utilizing all 3 dimensions in the same way, so it is more like 2D movement in that regard.
But it still applies to other use-cases outside of the main character's movements, such as with flying enemies, particles, and perhaps scenery.
@@10_days_till_xmas This made me think of flying around in Descent bumping into walls. It was the first game I played with fully 3D movement (up, down, rotation, rolling, etc.) and it got really confusing at times!
This very much applies to 4D games, where the ground is 3D, meaning you need to normalize a 3D movement vector.
So that's why arcs are so important. They keep the distance travelled consistent no matter what direction you go!
I wouldn't say "arcs". Rather "the unit circle", the thing they taught in trigonometry class.
@@nickpatella1525 would rather say vector math
Thanks ! Thanks to you I finally understood standardization 😁
quick note: normalising the vector will also INCREASE its value to 1 if you try to only move slightly.
You want to normalise _the direction_ and apply movement speed separately - you might run into unexpected behaviours otherwise
Excellent use of the short content for programming.
i am not kidding i was JUST listening to Colony 9 (Night) from Xenoblade DE, then i paused it to watch this video and THE SAME SONG STARTED PLAYING??? i thought my PC was acting up but nope, we live in a simulation
I have the subconscious urge to move diagonally in all movement games because of this phenomenon
This reminds me of Halo MCC where Diagonal movement inputs on the keyboard would make Master Chief move faster than usual.
This is also why in classic shooter speedrunning people tend to run diagonally.
some games intentionally make it a little faster so it doesn’t feel too slow
Yeah. That sounds like the way to do it. Just make it like this then add 10% and it might feel better.
Yeah, I came back to this video after playing Stardew Valley for the first time, vertical movement is painful in that game
lol, this so much like that without coyote time players feel betrayed and claim your controls are unresponsive..
I've known how to fix it for a while but I hate how sluggish it ends up feeling as a result, it's got that cursed vibe.
Its simple videos like this (and the graphics used) that motivate me again to do game development. I have been super interested in making games but always burn out because I dont have the artistic skills to make the graphics 😢
I love how you explain these concepts generally without specifying a game engine this help different game engine users to apply these cocepts according to game engine that they're using
Normalizing the vector is good for 3D games but when I developed my game, the diagonals felt slower despite it moving the same speed. So I made it 1.2x faster for diagonals on purpose and no one noticed in testing because it felt more normal than actually normalizing.
Thats probobly becouse the screen will move slower when you are still holding the same key since you cant move camera around to abuse fastness of it like in 3D games id say its a good idea to keep it fast like you did
little cheats like this are often necessary for things to feel good. it's particularly useful when running up slopes - players rarely want the physics to be realistic in that case, since it only slows them down
The thing about normalizing is that while you move at the same speed in the diagonal direction, you lose speed in the vertical or horizontal direction which discourages you to have a little fun when moving from point A to point B
@@Muho_is_meyeah I noticed this in Stardew Valley, the camera moves a lot slower when walking diagonally and it feels painful so I just avoid walking diagonally even though I know it’s the same speed
Thank you! I’m creating a game with a friend for school and this really helped!
Damn i finally understand what normalizing a vector means
Oh god that soundtrack brings back so many good memories!
This also explains why in older games like Doom you move faster diagonally
I like that the character moves faster in the diagonal direction
For anyone curious, you would want your speed to be reduced to sqrt(2)/2 per pixel in both directions when moving diagonally, which is about 0.7
Thank you for this ☺️ I bought your Udemy course last weekend and plan to follow it on the weekends
Ah, the xenoblade music fits in so many peaceful places
I appreciate the "Outside Colony 9 (Night)" as the music
awesome lesson dude
I've never noticed that the diagonal movement in my prototype was like this. Thanks!
I just want to say that I love your choice of background music (it's from Xenoblade which is one of my favorite games of all time)
normalizing diagonal movement alone would knock this pixel art character out of alignment with the pixel grid.
I honestly, like the diagonal speed, i feel like its mostly harmless and can be cool when adopted as a mechanic like in mother 3
Old RPG games like that would just let you move faster diagonally. It is actually pretty nice for gameplay, it feels good being able to move faster diagonally.
Yeah, looks better ngl
Now i understand, why the pythagorean theorem is important.
That instantly makes entire entire movement feel so much more natural! Well done!
Every beginners first problem, it's quite fun to encounter these kind of problems
I love the xenoblade bgm in the background! Nostalgic..
Game dev is the only reason I'm genuinely interested in math class now.
Yooo what a game changer! Quite literally. Thank you!
One of the first things I learnt during my game development studies! 😊
I knew it had to be hypotenuse related
please make more of these short videos... these short videos make those tutorial easily understandable.... maybe you can compile them someday for a small price
bro really say why to remember the pythagorean theorem
This fix is why walking diagonally into walls cuts your speed by ~30%.
I swear to god, if JRPGs fix this "bug", that will make me hate them even more
Very informative, thank you!
never thought the pythagorean theorem would be useful in any way possible
The Xenoblade Chronicles music makes this so nice and relaxing. Big fan.
yeah it’s colony 9
fun fact: controller sticks have this kind of "normalizing" built in. since it can only rotate in a circle, it can only read X and Y axis inputs within that circle, meaning all edges of the stick are a 1 input, in some combination of X and Y
this made me realize that sin²x+cos²x=1 also comes from the pythagorean theorem
trig moment
This is always something that you could do, but it's not always something that you should do.
For example, I know undertale doesn't do this, as it doesn't really have a reason to. If you were to do this to a game like undertale, you would be slowing down the movement for no good reason.
Now if you had a game where your speed not being consistent would upset the balance of the game, like a game where you spend a lot of time running away from enemies, this would be a pretty good change.
First time a TH-cam "Short" got me to subscribe to a channel. Well done!
That’s awesome. I am a programmer and I’ve made this kind of game before. I had wondered in the past why this happen. I always assumed it was 2x speed but the fact that it’s 1.4 makes complete sense and it’s really interesting.
How anyone who goes through school and college not knowing this already baffles me. It’s vectors 101
Well maybe I didn't graduate 4th grade
I actually kind of prefer the faster diagonal speed. I think having things that make big fans of the game faster or stronger without specifically adding in more equipment for them to grind to is underated. Being able to go 40% faster by figuring this out is so much more fun for me as a player than logging 20 hours for voots that do the same. And it being available from the start of the game just means that any returning player will be rewarded with tips and tricks from their intial play through. It will also help cut the time to retrace steps and travel times
It still feels faster, because the screen scrolls in both directions, instead of just one.
This is comparable to the decimal error oversight in epicness where you got a useless or a broken mechanic because you were missing or having a 0 too much
bro actually taught high school physics in 1 min.
not physics
@@Narvalo_Lastarnot high school
Bro taught one lesson of pre-algebra.
Yeah because he teaches it assuming that everyone here understands it, it’s more like a refresher
Alternatively, you could jeep this in as a movement tech for speedrunning.
jeep
@@noyz-anything keep*
i wrote a little multiplayer game as a kid where i noticed this, overcomplicated the math to fix it, and when me and my friends playtested it we decided it was more fun to keep fast the diagonal movement in
This "bug" existed in a lot of older games. I remember in Perfect Dark on the N64, there were cheats you could unlock by beating levels in a certain time on a specific difficulty. By using diagonal strafing, you could speed your character up and beat the level faster.
This is also an issue in any game with tile based movement, such as a lot of strategy games that use square grids. It's one of the reasons why a lot of people prefer hex grids, since there is no diagonal movement on a hex grid.
Very informative in terms of understanding why the problem is there. The video doesn't help much in terms of solving the problem though!
I know, right
normalize it !
ok, show me the math,
when moving diagonally divide the speed by √2 to normalize it
@firstname4337 divide the vector by the magnitude, also known as length. Generalized by sqrt(x^2 + y^2) for [x ,y] in R^2.
a general version of the solution where the angle of movement can be any angle (not only multiple of 45°) would be to use trigonometry ;
vx = cos(angle) * velocity
vy = sin(angle) * velocity
then use vx and vy to increment your character's position.
that's what you would need if your input system allow you to go in any direction (ex following your mouse)
yeah i get that, BUT HOW DO I ACTUALLY ADD THIS!!!!
you could just add (a) conditional check(s) for two perpendicular directions, and have them multiply ur effective speed by .6 to reduce it by 40%
@@ckorp666 doesn’t help
@@arctic8137 aight i wrote this real quick in GML, it should get the job done
- player object create:
spd = 6
diag_mult = 1
- player object step:
xmove = (keyboard_check(ord("D")) - keyboard_check(ord("A")))
ymove = (keyboard_check(ord("S")) - keyboard_check(ord("W")))
xspd = spd * xmove
yspd = spd * ymove
diag_mult = 1
if !(xmove = 0) && !(ymove = 0)
{
diag_mult = .6
}
x = x + (xspd * diag_mult)
y = y + (yspd * diag_mult)
This is probably a late reply but oh well. To "normalise" like it says in the video, you divide the X and Y by the distance moved. So, If you are moving orthogonally, or vertically, divide the X and Y by 1. If you are moving diagonally, divide the X and Y by 1.4. The key thing is to slow yourself down if you are going diagonal.
To implement this for any direction, you can do something like:
(set initial movement)
x = 2
y = 3
(work out length of move)
length = √(x * x + y * y)
(normalise movement by dividing by length)
x / length
y / length
(movement should now be exactly 1 unit in any direction) (multiply by speed or whatever for final value).
The other comment replied with multiplication probably because that's quicker for a computer to do iirc.
@@dephoro Sure, I was just explaining how to "normalise" a vector, so I kept the example as simple as possible. Normally my implementation doesn't use any branches at all. Normally it's just something like:
- Get initial vector from input.
- Normalise the vector (should just be a function called Normalise)
Literally two function calls, you would be hard pressed to find a solution cleaner than that. The Normalise function is also quite a common operation that has been optimised to death(atleast with improvements to sqrt). You can modify it further if you need extra features, but I don't think it gets much simpler or faster than just input.Normalise(). If your engine doesn't have a native Normalise(), you can implement it yourself using pythagoras (it's a single line for the equation, and doesn't involve any branches).
Normalise just takes a vector (an X and Y value) and outputs circular values for them, exactly as you describe(It outputs on a unit circle though). What is the difference between your solution and just normalise?
This is why vectoring exists in Super Mario Odyssey and 3D World + Bowser’s Fury speedruns
This didn't actually explain anything but it's hard to give programming tutorials through shorts, so I applaud you for trying anyway
Escapists has that movement and it feels so good abusing it
That’s why speed runners move diagonally in morrowind
That remembers me the fact that some old games forgot it in some situations like in hitman bloodmoney where you're faster when dragging a body in diagonal.
I had never thought about normalizing vectors as moving them to the origin and shrinking them to fit. Absolutely epic.
Of all the math I’ve learned until now, the pythagorean theorem seems to be the only one that keeps popping up as useful
Bread and Butter for speedy movement in 007 Goldeneye (N64).
Several Zelda games even don’t mind that acceleration
That little guy needs a diagonal movement texture!