@@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.
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
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)
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.
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
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
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.
@@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?"
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.
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
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 😢
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 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
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.
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
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
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
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.
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.
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
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)
I recently made a math-based marketplace asset for this. Was google searching previous solutions for it... I still feel very good about the asset and still feel like it solved a big problem. That 0.6 multiplier will only work at a 45* angle. I completely circularized it in a single macro with no execution nodes, and you can also add custom movement curves. So like, go forward full speed but backwards at 70% or something. "Movement Input Correction & Customization" on UE Marketplace.
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.
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…
"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.
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
"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
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.
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
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
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 love the xenoblade bgm in the background! Nostalgic..
Bro the Xenoblade music! Mad respect.
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
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
I knew it had to be hypotenuse related
Now make them face diagonally, too.
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
Speedrunners want to know your location
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
Unreal tournament diagonal movement makes so much sense now.
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
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
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
When you thought math was stupid but wanted to design games 😂
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 will refer to this video every time I make a top down game. Thanks so much! Also appreciate the Xenoblade music.
This is why you zig-zag when people are shooting at you irl
This is why vectoring exists in Super Mario Odyssey and 3D World + Bowser’s Fury speedruns
no wonder my game character felt a little fast when moving diagonally thank you so much I forgot about this lol
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
Pythagorean Theorem, my beloved.
Day 0 of not using the Pythagorean theorem as an adult in the real world
I'm working on a top down adventure game and this actually helped fix my diagonal movenment. Thanks!
Which engine are you using?
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..
Loving the good info with chill Xenoblade music backing it up
Bread and Butter for speedy movement in 007 Goldeneye (N64).
This is also why in classic shooter speedrunning people tend to run diagonally.
Ah, the xenoblade music fits in so many peaceful places
The Xenoblade Chronicles music makes this so nice and relaxing. Big fan.
yeah it’s colony 9
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 😢
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.
Excellent use of the short content for programming.
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
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.
This also explains why in older games like Doom you move faster diagonally
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
I swear to god, if JRPGs fix this "bug", that will make me hate them even more
once you mentioned the diagonal movement I exactly knew you gonna pull the pythagorean theorem
Now i understand, why the pythagorean theorem is important.
Oh god that soundtrack brings back so many good memories!
Of all the math I’ve learned until now, the pythagorean theorem seems to be the only one that keeps popping up as useful
This reminds me of Halo MCC where Diagonal movement inputs on the keyboard would make Master Chief move faster than usual.
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
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)
I love playing Doom diagonally
"You might notice the character moves faster in the diagonal direction,"
*Phoon's theme starts playing*
Thank you for this ☺️ I bought your Udemy course last weekend and plan to follow it on the weekends
I've never noticed that the diagonal movement in my prototype was like this. Thanks!
awesome lesson dude
the xenoblade music just made this so calm!
Game dev is the only reason I'm genuinely interested in math class now.
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
never thought the pythagorean theorem would be useful in any way possible
That’s why speed runners move diagonally in morrowind
Very informative, thank you!
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.
This fix is why walking diagonally into walls cuts your speed by ~30%.
When what you learn in math actually comes in clutch
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
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'm so used to the faster diagonal movement that normalizing it makes it feel super slow now
I never realized why diagonal movement was so uncanny, this was so helpful
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
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
Naughty dog programmers while making crash bandicoot: I'll pretend I didn't hear that
I thought this was going to be about fixing diagonal movement in pixelart games, where the low resolution makes the camera movement shaky
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.
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
the one and only time that will come in handy
Luna Game 3D has this error which helps immensely on speedruns
Alternatively, you could jeep this in as a movement tech for speedrunning.
jeep
@@noyz-anything keep*
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)
Escapists has that movement and it feels so good abusing it
This UA-cam short turned into a maths class 😂
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)
I recently made a math-based marketplace asset for this. Was google searching previous solutions for it... I still feel very good about the asset and still feel like it solved a big problem. That 0.6 multiplier will only work at a 45* angle. I completely circularized it in a single macro with no execution nodes, and you can also add custom movement curves. So like, go forward full speed but backwards at 70% or something. "Movement Input Correction & Customization" on UE Marketplace.
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.
So thats what the math teacher was about that math will help you in the future...
I like that the character moves faster in the diagonal direction
No way this guy just found the daily usage of Pythagorean theorem
honestly i like the faster diagonal movement as it conveys a sort of feint
As soon as he was mentioning 1.4 px, i was like "mans actually making use of the pythagorean formula" 😂
I kid you not, we had this in math class last week
I had this exact issue coding a scratch game. I remember how proud I was when I figured out how to normalise the diagonal movement with Pythagorus.
Several Zelda games even don’t mind that acceleration
Undertale is a great representation of the fast diagonal movement
I appreciate the "Outside Colony 9 (Night)" as the music
It's funny that this even happens in famous games like Chrono Trigger
When I was in the primary school I always thought that vectors are useless, now I see I was wrong
Dang, bro really just pulled out the Pythagorean theorem on me. Ok, I see you.
Teachers: “This is something you’ll need to know in the real world.”
The one time I actually need to use it for:
I love how you used two different algebra topics, even one from linear algebra, which is what I’m learning right now