How to fix your diagonal movement!

Поділитися
Вставка
  • Опубліковано 26 січ 2022
  • Diagonal movement may be easy to implement, but you might want to consider normalizing your vectors.
    #gamedev #shorts
  • Ігри

КОМЕНТАРІ • 1,7 тис.

  • @heartofdawnlight
    @heartofdawnlight 6 місяців тому +39963

    speedrunners hate this one programming technique

    • @-Yello-
      @-Yello- 6 місяців тому +628

      I was thinkin the same thing lol

    • @729MendicantTide
      @729MendicantTide 6 місяців тому +228

      Goldeneye players too

    • @ollllj
      @ollllj 6 місяців тому +506

      we need a list of 3d games, that fail to normalize some movement vectors.

    • @danolantern6030
      @danolantern6030 6 місяців тому +232

      Speedrunners when not every single little exploit is kept in for them and not every little aspect of a game is designed around them

    • @porkt3887
      @porkt3887 6 місяців тому +259

      ​​@@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

  • @rory8182
    @rory8182 6 місяців тому +17258

    This is why they move diagonally in original Doom speedruns

    • @Kushibunny
      @Kushibunny 6 місяців тому +863

      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.

    • @platinumfactor
      @platinumfactor 6 місяців тому +414

      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.

    • @wileecoyotegenius5955
      @wileecoyotegenius5955 6 місяців тому +28

      And Goldeneye

    • @threeco2350
      @threeco2350 6 місяців тому +18

      ​@@platinumfactoryes, a good example of the movement shown in this video would be diablo 1.

    • @TF2Starlight
      @TF2Starlight 6 місяців тому +5

      @@platinumfactoryea you can run along a wall and run faster…

  • @Neodel
    @Neodel 6 місяців тому +915

    "When will we ever use Pythagoras in real life?"
    Clarification: this comment is mocking people who think this

    • @DasOrange
      @DasOrange 2 місяці тому +71

      Pythagorian theorem is one of my most used formulas. Trigonometry is so useful.

    • @MagikalKrabical
      @MagikalKrabical 2 місяці тому +34

      Pythagoras is the most used theorem outside of school and direct mathematics istg

    • @jibstacking
      @jibstacking 2 місяці тому +11

      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

    • @danielkoch8736
      @danielkoch8736 2 місяці тому +7

      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

    • @Ubermenschgaming_
      @Ubermenschgaming_ 2 місяці тому

      He explained it explicitly trying to fit it to use that math technique.
      Still useless lol.

  • @pinkie723
    @pinkie723 5 місяців тому +102

    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

    • @varglbargl
      @varglbargl 3 місяці тому +24

      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

    • @peng0_266
      @peng0_266 2 місяці тому +1

      i dont think godbridging exists in topdown pixel games though

    • @raven-a
      @raven-a 2 місяці тому

      ​​@@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)

    • @happy_bracket
      @happy_bracket 2 місяці тому +2

      ​@@raven-aanother solution: make the character's minimal speed X pixels/frame and round normalized diagonal velocity to nearest integer.

    • @allergic_to_zucchini_noodles
      @allergic_to_zucchini_noodles 2 місяці тому +1

      it's extra math, normalizing the vector isn't as simple as dividing by a specific factor if the game allows multiple movement speeds

  • @thelred-ph3lq
    @thelred-ph3lq Рік тому +9830

    Note to self: When escaping from danger run diagonally. Those straight line runners will have a hell of a time trying to catch up.

    • @meteylmaz4366
      @meteylmaz4366 10 місяців тому +419

      Remember, you don’t need to outrun the monster. Just outrun your friends!

    • @ChronoNewton
      @ChronoNewton 8 місяців тому +29

      lmao🤣🤣

    • @ultra-doggofn9788
      @ultra-doggofn9788 6 місяців тому +7

      😂😂

    • @GunSpyEnthusiast
      @GunSpyEnthusiast 6 місяців тому

      @@meteylmaz4366 note to self, run at an angle which you can run directly to your friend to clothesline them, whilst moving diagonally.

    • @Sjorsje
      @Sjorsje 6 місяців тому +11

      The World is not Enough on N64 in a nutshell

  • @kennethha8173
    @kennethha8173 7 місяців тому +4758

    "When are we ever going to need to use the Pythagoras theorem?"

    • @19Szabolcs91
      @19Szabolcs91 6 місяців тому +639

      It"s also literally one of the most commonly used formulas in real life to measure distances in all kinds of situations.

    • @totally_not_a_bot
      @totally_not_a_bot 6 місяців тому +63

      ​@@19Szabolcs91Measuring stuff uses trig more than pythagoras. It comes in handy for setting up perpendiculars though.

    • @mohsinuddin7049
      @mohsinuddin7049 6 місяців тому +246

      “You won’t, but the smarter kids will.”

    • @DimT670
      @DimT670 6 місяців тому +19

      ​@@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

    • @SpunkMayo
      @SpunkMayo 5 місяців тому +95

      My dad in school: "Fuck this algebra and geometry shit I'll never use it"
      My dad at work: is a carpenter

  • @MrSirSquishy
    @MrSirSquishy 2 місяці тому +22

    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.

    • @onegoesdown
      @onegoesdown День тому +2

      This is such an important thing. So many devs lost this mindset.

  • @cdscissor
    @cdscissor 6 місяців тому +25

    So that's why arcs are so important. They keep the distance travelled consistent no matter what direction you go!

    • @nickpatella1525
      @nickpatella1525 5 місяців тому +3

      I wouldn't say "arcs". Rather "the unit circle", the thing they taught in trigonometry class.

    • @Erlisch1337
      @Erlisch1337 2 місяці тому +1

      @@nickpatella1525 would rather say vector math

  • @glltyt
    @glltyt 2 роки тому +5715

    This is the first time I've ever understood the relation between the game math and the result. Thank you so much.

    • @ravihlb
      @ravihlb 6 місяців тому +15

      Same!

    • @hikari1690
      @hikari1690 6 місяців тому +3

      I just clicky cause I wanty. Sides, could use polar coordinates instead of this Kardashian coordinates and save some computing power 🤣

    •  6 місяців тому +14

      ​@@hikari1690That would work, but wouldn't save any computing power.

    • @squishyushi
      @squishyushi 5 місяців тому

      Big brain

    • @clumsypanda7433
      @clumsypanda7433 5 місяців тому

      ​@@hikari1690Cartesian*. Kardashian coordinates would be used to measure amount of plastic in a bimbo

  • @TheGarcia122007
    @TheGarcia122007 Рік тому +7933

    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 😅

    • @olutukko2681
      @olutukko2681 Рік тому +471

      Go for engineering studies and oh boy you're going to need them a lot :D

    • @uncensored393
      @uncensored393 Рік тому +328

      ​@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.

    • @sebastiangudino9377
      @sebastiangudino9377 Рік тому +212

      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

    • @ThatdudeAry
      @ThatdudeAry 11 місяців тому +67

      For everyday life? Probably not, but math is the heart engineering, science and coding imo

    • @AceTheAro7
      @AceTheAro7 10 місяців тому +75

      I must say out of everything,
      Pythagorean theorem is the most used formula ever

  • @neeha9449
    @neeha9449 6 місяців тому +1

    I love the xenoblade bgm in the background! Nostalgic..

  • @Xeno_Solarus
    @Xeno_Solarus 6 місяців тому +17

    Bro the Xenoblade music! Mad respect.

  • @GugureSux
    @GugureSux Рік тому +971

    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.

    • @vulkanosaure
      @vulkanosaure 9 місяців тому +36

      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

    • @yapflipthegrunt4687
      @yapflipthegrunt4687 6 місяців тому +57

      Looking down to run the game at a constant 60fps is another speedrun strat for that game.

    • @19Szabolcs91
      @19Szabolcs91 6 місяців тому +1

      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...

    • @RipVanFish09
      @RipVanFish09 6 місяців тому +3

      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

    • @skad2058
      @skad2058 6 місяців тому

      ​@@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

  • @stellar7933
    @stellar7933 Рік тому +1667

    Love how algebra actually becomes so helpful when you get into programming

    • @janpapai9205
      @janpapai9205 7 місяців тому +96

      Its kinda more linear geometrics then algebra bc the formula is about a triangle and its sides but nevermind

    • @madscientist14
      @madscientist14 7 місяців тому +60

      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.

    • @bigfatpandalaktana2747
      @bigfatpandalaktana2747 6 місяців тому +41

      Welcome to engineering - where we actually use the maths we were taught in school

    • @aBucketOfPuppies
      @aBucketOfPuppies 6 місяців тому +10

      I laugh when I think back to all the kids who thought that math was useless because they just wanted to become programmers

    • @saechaol
      @saechaol 6 місяців тому +8

      especially when you take linear algebra and it’s basically fundamental to computing graphics and games

  • @darkjoltgames
    @darkjoltgames 6 місяців тому +2

    I knew it had to be hypotenuse related

  • @TheGunguy461
    @TheGunguy461 6 місяців тому +1

    Now make them face diagonally, too.

  • @shad-fanatic
    @shad-fanatic 6 місяців тому +1435

    As the artist of an indie team, I really want that guy to have diagonal animations

    • @shad-fanatic
      @shad-fanatic 6 місяців тому +31

      👍

    • @caldercockatoo2234
      @caldercockatoo2234 6 місяців тому +37

      @@shad-fanaticWhy’d you reply to your one comment?

    • @shad-fanatic
      @shad-fanatic 6 місяців тому +90

      Someone else commented before, but I think they deleted it

    • @why_i_game
      @why_i_game 6 місяців тому +58

      @@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?"

    • @shad-fanatic
      @shad-fanatic 6 місяців тому +6

      yes

  • @TheEuropeMan
    @TheEuropeMan 6 місяців тому +348

    Speedrunners want to know your location

  • @Pie_Mastah
    @Pie_Mastah 6 місяців тому +12

    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

    • @sealiteral432
      @sealiteral432 3 місяці тому

      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
      @michawhite7613 3 місяці тому

      I think usually characters move more than one pixel per frame.

    • @Pie_Mastah
      @Pie_Mastah 3 місяці тому

      @@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.

    • @michawhite7613
      @michawhite7613 3 місяці тому

      @@Pie_Mastah My intuition is that the difference between 8 pixels and 9 pixels isn't noticeable, but I could be wrong.

    • @Pie_Mastah
      @Pie_Mastah 3 місяці тому +1

      @@michawhite7613 only noticeable when in a pixel art style, when 8-9 pixels is like half the size of the player

  • @createmakestuff4694
    @createmakestuff4694 6 днів тому

    Unreal tournament diagonal movement makes so much sense now.

  • @errantcondor9349
    @errantcondor9349 7 місяців тому +218

    I could swear I heard Colony 9 in the background. I love you.

    • @gavinli1368
      @gavinli1368 7 місяців тому +38

      Yeah!!! Xenoblade OST fans! Escoecially the night time theme!!!

    • @waltercardcollector
      @waltercardcollector 6 місяців тому +19

      Yess! Colony 9 night music is one of my favorite video game music pieces of all time.

    • @pedrobeckup456
      @pedrobeckup456 6 місяців тому +13

      I love this song!!

    • @Betsy7Cat
      @Betsy7Cat 6 місяців тому +13

      @@gavinli1368I recognized it right away bc it’s one of like 5 songs from the game I use to fall asleep lmao

    • @Sharklady594
      @Sharklady594 5 місяців тому +3

      I immediately knew it was a xenoblade song I just didn’t know which one, thank you

  • @tiger_vii
    @tiger_vii Рік тому +361

    I can't believe I fell asleep during maths classes..... Damn it!

    • @zaplershorts7783
      @zaplershorts7783 Рік тому +6

      Ik I’m late at answering but, I did too 😅

    • @erikblaas5826
      @erikblaas5826 9 місяців тому +11

      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)

    • @ClodsireBcuzYes
      @ClodsireBcuzYes 6 місяців тому +12

      nah its not ur fault, they make it as boring as one could imagine

    • @theoriginaldrdust
      @theoriginaldrdust 4 місяці тому

      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

    • @tiger_vii
      @tiger_vii 4 місяці тому

      @@zaplershorts7783 were u still sleeping

  • @equal2873
    @equal2873 5 місяців тому +5

    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.

    • @nidbahn
      @nidbahn 4 місяці тому

      divide the speed by sqrt2 and put it in both x and y of movement vector

  • @chance713
    @chance713 6 місяців тому +1

    When you thought math was stupid but wanted to design games 😂

  • @linksword7110
    @linksword7110 2 роки тому +447

    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

    • @agent-33
      @agent-33 2 роки тому +62

      Thanks. It's a shame the uploader didn't give the actual answer and just "blah blah got it? ok bye" to us.

    • @alessioturco953
      @alessioturco953 2 роки тому +2

      where shoul i copy it? in fuction load or update

    • @pyrytheburger3869
      @pyrytheburger3869 2 роки тому

      @@alessioturco953 update probably

    • @linksword7110
      @linksword7110 2 роки тому +31

      i would recommend learning how normalization works with math.

    • @tofame4291
      @tofame4291 Рік тому +11

      @@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

  • @jadenh_gamedev
    @jadenh_gamedev Рік тому +122

    I will refer to this video every time I make a top down game. Thanks so much! Also appreciate the Xenoblade music.

  • @scoobydoobies
    @scoobydoobies 6 місяців тому +1

    This is why you zig-zag when people are shooting at you irl

  • @Pr0t4t0
    @Pr0t4t0 5 місяців тому +1

    This is why vectoring exists in Super Mario Odyssey and 3D World + Bowser’s Fury speedruns

  • @devmarboy4045
    @devmarboy4045 9 місяців тому +38

    no wonder my game character felt a little fast when moving diagonally thank you so much I forgot about this lol

  • @PieDivide
    @PieDivide Рік тому +12

    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

  • @GlitchedBlox
    @GlitchedBlox 5 місяців тому +1

    Pythagorean Theorem, my beloved.

  • @CaddebostanRdr
    @CaddebostanRdr 6 місяців тому +1

    Day 0 of not using the Pythagorean theorem as an adult in the real world

  • @KettleClogScratch
    @KettleClogScratch 10 місяців тому +21

    I'm working on a top down adventure game and this actually helped fix my diagonal movenment. Thanks!

  • @ndererseje1077
    @ndererseje1077 6 місяців тому +54

    some games intentionally make it a little faster so it doesn’t feel too slow

    • @Chronon88
      @Chronon88 5 місяців тому +3

      Yeah. That sounds like the way to do it. Just make it like this then add 10% and it might feel better.

    • @eVCANN
      @eVCANN 5 місяців тому +1

      Yeah, I came back to this video after playing Stardew Valley for the first time, vertical movement is painful in that game

    • @georgelionon9050
      @georgelionon9050 5 місяців тому

      lol, this so much like that without coyote time players feel betrayed and claim your controls are unresponsive..

  • @tiki-nagasvoice7919
    @tiki-nagasvoice7919 6 місяців тому

    Loving the good info with chill Xenoblade music backing it up

  • @Allplussomeminus
    @Allplussomeminus Місяць тому

    Bread and Butter for speedy movement in 007 Goldeneye (N64).

  • @NotLordAsshat
    @NotLordAsshat 6 місяців тому +20

    This is also why in classic shooter speedrunning people tend to run diagonally.

  • @KIRBOFLURBO
    @KIRBOFLURBO 6 місяців тому +7

    Ah, the xenoblade music fits in so many peaceful places

  • @katsureiwarui8615
    @katsureiwarui8615 6 місяців тому +1

    The Xenoblade Chronicles music makes this so nice and relaxing. Big fan.

  • @UltiemeHack
    @UltiemeHack День тому

    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 😢

  • @justaway_of_the_samurai
    @justaway_of_the_samurai 6 місяців тому +24

    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.

    • @10_days_till_xmas
      @10_days_till_xmas 6 місяців тому +2

      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

    • @acebandge5293
      @acebandge5293 6 місяців тому

      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.

    • @justaway_of_the_samurai
      @justaway_of_the_samurai 6 місяців тому

      @@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.

    • @why_i_game
      @why_i_game 6 місяців тому +1

      @@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!

    • @nickpatella1525
      @nickpatella1525 5 місяців тому

      This very much applies to 4D games, where the ground is 3D, meaning you need to normalize a 3D movement vector.

  • @alexatedw
    @alexatedw Рік тому +17

    Excellent use of the short content for programming.

  • @arttukettunen5757
    @arttukettunen5757 5 місяців тому +1

    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

  • @codahighland
    @codahighland 6 місяців тому +2

    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.

  • @Eddman368
    @Eddman368 7 місяців тому +7

    This also explains why in older games like Doom you move faster diagonally

  • @AacatNet
    @AacatNet 6 місяців тому +22

    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.

    • @Muho_is_me
      @Muho_is_me 6 місяців тому +4

      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

    • @duncathan_salt
      @duncathan_salt 6 місяців тому +9

      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

    • @hugoguh1
      @hugoguh1 6 місяців тому +3

      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

    • @eVCANN
      @eVCANN 5 місяців тому

      @@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

  • @MinorLife10
    @MinorLife10 6 місяців тому +4

    I swear to god, if JRPGs fix this "bug", that will make me hate them even more

  • @gmdascensia
    @gmdascensia 4 місяці тому

    once you mentioned the diagonal movement I exactly knew you gonna pull the pythagorean theorem

  • @DerAndersdenker
    @DerAndersdenker 9 місяців тому +4

    Now i understand, why the pythagorean theorem is important.

  • @MaisistkeinGemuese
    @MaisistkeinGemuese 6 місяців тому +6

    Oh god that soundtrack brings back so many good memories!

  • @ImCrowned76
    @ImCrowned76 3 місяці тому

    Of all the math I’ve learned until now, the pythagorean theorem seems to be the only one that keeps popping up as useful

  • @aryamaanborah7698
    @aryamaanborah7698 4 місяці тому

    This reminds me of Halo MCC where Diagonal movement inputs on the keyboard would make Master Chief move faster than usual.

  • @mohamedmoh5789
    @mohamedmoh5789 Рік тому +7

    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

  • @waltercardcollector
    @waltercardcollector 6 місяців тому +18

    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)

  • @TheSpiritedFendron
    @TheSpiritedFendron 6 місяців тому +1

    I love playing Doom diagonally

  • @ab3ki84hayate
    @ab3ki84hayate 4 місяці тому

    "You might notice the character moves faster in the diagonal direction,"
    *Phoon's theme starts playing*

  • @jellybon
    @jellybon Рік тому +20

    Thank you for this ☺️ I bought your Udemy course last weekend and plan to follow it on the weekends

  • @esben181
    @esben181 Рік тому +4

    I've never noticed that the diagonal movement in my prototype was like this. Thanks!

  • @wasquash
    @wasquash 6 місяців тому +2

    awesome lesson dude

  • @christianGamerDude
    @christianGamerDude 29 днів тому

    the xenoblade music just made this so calm!

  • @mom0367
    @mom0367 Рік тому +12

    Game dev is the only reason I'm genuinely interested in math class now.

  • @laptoprelaks
    @laptoprelaks Рік тому +3

    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

  • @thje_mop
    @thje_mop 4 місяці тому

    never thought the pythagorean theorem would be useful in any way possible

  • @wiiblewobble
    @wiiblewobble 5 місяців тому

    That’s why speed runners move diagonally in morrowind

  • @ismyname_jep1394
    @ismyname_jep1394 2 роки тому +7

    Very informative, thank you!

  • @akunbora
    @akunbora Місяць тому +4

    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.

  • @James2210
    @James2210 3 місяці тому

    This fix is why walking diagonally into walls cuts your speed by ~30%.

  • @guccilix7101
    @guccilix7101 5 місяців тому

    When what you learn in math actually comes in clutch

  • @girla9480
    @girla9480 6 місяців тому +28

    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.

    • @henrioak
      @henrioak 6 місяців тому +1

      Yeah, looks better ngl

  • @ChickenTandies
    @ChickenTandies 5 місяців тому +7

    How anyone who goes through school and college not knowing this already baffles me. It’s vectors 101

    • @miles11we
      @miles11we 3 місяці тому +1

      Well maybe I didn't graduate 4th grade

  • @elowin1691
    @elowin1691 5 місяців тому

    I'm so used to the faster diagonal movement that normalizing it makes it feel super slow now

  • @zants_
    @zants_ 6 місяців тому +1

    I never realized why diagonal movement was so uncanny, this was so helpful

  • @soloshottie
    @soloshottie 6 місяців тому +6

    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

    • @nidbahn
      @nidbahn 4 місяці тому +2

      this made me realize that sin²x+cos²x=1 also comes from the pythagorean theorem

    • @mmmmmmok5292
      @mmmmmmok5292 2 місяці тому

      trig moment

  • @dikshantchaturvedi3099
    @dikshantchaturvedi3099 Рік тому +5

    bro actually taught high school physics in 1 min.

    • @Narvalo_Lastar
      @Narvalo_Lastar 11 місяців тому +1

      not physics

    • @sanzharzaitenov5268
      @sanzharzaitenov5268 11 місяців тому +1

      ​@@Narvalo_Lastarnot high school

    • @chaotickreg7024
      @chaotickreg7024 9 місяців тому +4

      Bro taught one lesson of pre-algebra.

    • @eVCANN
      @eVCANN 5 місяців тому

      Yeah because he teaches it assuming that everyone here understands it, it’s more like a refresher

  • @ZeroStrife1396
    @ZeroStrife1396 6 місяців тому

    Naughty dog programmers while making crash bandicoot: I'll pretend I didn't hear that

  • @szabotudor
    @szabotudor Місяць тому +1

    I thought this was going to be about fixing diagonal movement in pixelart games, where the low resolution makes the camera movement shaky

  • @Phychologik
    @Phychologik 8 місяців тому +7

    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.

  • @addictionsucks8848
    @addictionsucks8848 3 місяці тому +4

    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

  • @ClodsireBcuzYes
    @ClodsireBcuzYes Місяць тому +1

    the one and only time that will come in handy

  • @Aerialyn
    @Aerialyn 5 місяців тому +1

    Luna Game 3D has this error which helps immensely on speedruns

  • @alexandredesouza3692
    @alexandredesouza3692 9 місяців тому +12

    Alternatively, you could jeep this in as a movement tech for speedrunning.

  • @gravestron9695
    @gravestron9695 2 роки тому +10

    Very informative in terms of understanding why the problem is there. The video doesn't help much in terms of solving the problem though!

    • @firstname4337
      @firstname4337 2 роки тому +2

      I know, right
      normalize it !
      ok, show me the math,

    • @dreamy97836
      @dreamy97836 Рік тому

      when moving diagonally divide the speed by √2 to normalize it

    • @warguy6474
      @warguy6474 7 місяців тому

      ​@firstname4337 divide the vector by the magnitude, also known as length. Generalized by sqrt(x^2 + y^2) for [x ,y] in R^2.

    • @vulkanosaure
      @vulkanosaure 6 місяців тому

      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)

  • @darkgub
    @darkgub 6 місяців тому

    Escapists has that movement and it feels so good abusing it

  • @WilliamGaming100
    @WilliamGaming100 2 місяці тому

    This UA-cam short turned into a maths class 😂

  • @arctic8137
    @arctic8137 Рік тому +6

    yeah i get that, BUT HOW DO I ACTUALLY ADD THIS!!!!

    • @ckorp666
      @ckorp666 Рік тому +1

      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%

    • @arctic8137
      @arctic8137 Рік тому

      @@ckorp666 doesn’t help

    • @ckorp666
      @ckorp666 Рік тому

      @@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)

    • @dephoro
      @dephoro Рік тому

      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.

    • @oscarsmith-jones4108
      @oscarsmith-jones4108 Рік тому +1

      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.

  • @nightfarming4205
    @nightfarming4205 2 дні тому

    So thats what the math teacher was about that math will help you in the future...

  • @violetlavender9504
    @violetlavender9504 6 місяців тому +1

    I like that the character moves faster in the diagonal direction

  • @utellmewhatitshouldbe7912
    @utellmewhatitshouldbe7912 6 місяців тому

    No way this guy just found the daily usage of Pythagorean theorem

  • @Poopholder
    @Poopholder 5 місяців тому

    honestly i like the faster diagonal movement as it conveys a sort of feint

  • @HypedKryptic
    @HypedKryptic 6 місяців тому

    As soon as he was mentioning 1.4 px, i was like "mans actually making use of the pythagorean formula" 😂

  • @teroblepuns
    @teroblepuns 6 місяців тому +1

    I kid you not, we had this in math class last week

  • @ernstnolte9396
    @ernstnolte9396 4 місяці тому

    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.

  • @nikitapower947
    @nikitapower947 5 місяців тому

    Several Zelda games even don’t mind that acceleration

  • @t9foggy
    @t9foggy 5 місяців тому

    Undertale is a great representation of the fast diagonal movement

  • @guimon78
    @guimon78 2 місяці тому

    I appreciate the "Outside Colony 9 (Night)" as the music

  • @giow1546
    @giow1546 2 місяці тому

    It's funny that this even happens in famous games like Chrono Trigger

  • @seeyainvalhalla8702
    @seeyainvalhalla8702 4 місяці тому

    When I was in the primary school I always thought that vectors are useless, now I see I was wrong

  • @Ridlay_
    @Ridlay_ 4 місяці тому

    Dang, bro really just pulled out the Pythagorean theorem on me. Ok, I see you.

  • @keroadh1455
    @keroadh1455 6 місяців тому

    Teachers: “This is something you’ll need to know in the real world.”
    The one time I actually need to use it for:

  • @diitrii
    @diitrii 4 місяці тому +1

    I love how you used two different algebra topics, even one from linear algebra, which is what I’m learning right now