How to fix your diagonal movement!

แชร์
ฝัง
  • เผยแพร่เมื่อ 21 ส.ค. 2024
  • Diagonal movement may be easy to implement, but you might want to consider normalizing your vectors.
    #gamedev #shorts

ความคิดเห็น • 1.8K

  • @heartofdawnlight
    @heartofdawnlight 8 หลายเดือนก่อน +41534

    speedrunners hate this one programming technique

    • @-Yello-
      @-Yello- 8 หลายเดือนก่อน +655

      I was thinkin the same thing lol

    • @729MendicantTide
      @729MendicantTide 8 หลายเดือนก่อน +242

      Goldeneye players too

    • @ollllj
      @ollllj 8 หลายเดือนก่อน +531

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

    • @danolantern6030
      @danolantern6030 8 หลายเดือนก่อน +242

      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 8 หลายเดือนก่อน +269

      ​​@@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 8 หลายเดือนก่อน +18057

    This is why they move diagonally in original Doom speedruns

    • @Kushibunny
      @Kushibunny 8 หลายเดือนก่อน +899

      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 8 หลายเดือนก่อน +425

      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 8 หลายเดือนก่อน +29

      And Goldeneye

    • @threeco2350
      @threeco2350 8 หลายเดือนก่อน +19

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

    • @TF2Starlight
      @TF2Starlight 8 หลายเดือนก่อน +6

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

  • @Casual330
    @Casual330 8 วันที่ผ่านมา +11

    Running in zig-zags never made more sense

  • @pinkie723
    @pinkie723 7 หลายเดือนก่อน +263

    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 5 หลายเดือนก่อน +57

      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 4 หลายเดือนก่อน +2

      i dont think godbridging exists in topdown pixel games though

    • @raven-a
      @raven-a 4 หลายเดือนก่อน

      ​​@@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 4 หลายเดือนก่อน +2

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

    • @EphemeralPseudonym
      @EphemeralPseudonym 4 หลายเดือนก่อน +2

      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 ปีที่แล้ว +10004

    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 ปีที่แล้ว +437

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

    • @ChronoNewton
      @ChronoNewton 10 หลายเดือนก่อน +29

      lmao🤣🤣

    • @ultra-doggofn9788
      @ultra-doggofn9788 8 หลายเดือนก่อน +7

      😂😂

    • @GunSpyEnthusiast
      @GunSpyEnthusiast 8 หลายเดือนก่อน

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

    • @Sjorsje
      @Sjorsje 8 หลายเดือนก่อน +11

      The World is not Enough on N64 in a nutshell

  • @glltyt
    @glltyt 2 ปีที่แล้ว +5786

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

    • @ravihlb
      @ravihlb 8 หลายเดือนก่อน +15

      Same!

    • @hikari1690
      @hikari1690 8 หลายเดือนก่อน +4

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

    •  8 หลายเดือนก่อน +15

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

    • @squishyushi
      @squishyushi 8 หลายเดือนก่อน

      Big brain

    • @clumsypanda7433
      @clumsypanda7433 7 หลายเดือนก่อน

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

  • @Neodx2
    @Neodx2 8 หลายเดือนก่อน +1427

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

    • @DasOrange
      @DasOrange 4 หลายเดือนก่อน +95

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

    • @MagikalKrabical
      @MagikalKrabical 4 หลายเดือนก่อน +43

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

    • @jibstacking
      @jibstacking 4 หลายเดือนก่อน +14

      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 4 หลายเดือนก่อน +15

      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_ 4 หลายเดือนก่อน +1

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

  • @MrSirSquishy
    @MrSirSquishy 4 หลายเดือนก่อน +93

    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 หลายเดือนก่อน +13

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

    • @mchlkpng
      @mchlkpng หลายเดือนก่อน +13

      I tried normalizing movement for something. It really didn't feel right. Even if you're going the same speed, it feels slower

    • @anonymousapproximation8549
      @anonymousapproximation8549 หลายเดือนก่อน +6

      ​@@mchlkpngBecause you basically are. You're not going forwards as fast, nor are you moving to the side as fast.

    • @mchlkpng
      @mchlkpng หลายเดือนก่อน

      @@anonymousapproximation8549 true

    • @marcxworld5708
      @marcxworld5708 12 วันที่ผ่านมา

      Nah its not better lol

  • @kennethha8173
    @kennethha8173 9 หลายเดือนก่อน +4823

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

    • @19Szabolcs91
      @19Szabolcs91 8 หลายเดือนก่อน +642

      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 8 หลายเดือนก่อน +64

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

    • @mohsinuddin7049
      @mohsinuddin7049 8 หลายเดือนก่อน +253

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

    • @DimT670
      @DimT670 8 หลายเดือนก่อน +20

      ​@@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 8 หลายเดือนก่อน +96

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

  • @stellar7933
    @stellar7933 ปีที่แล้ว +1681

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

    • @janpapai9205
      @janpapai9205 9 หลายเดือนก่อน +97

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

    • @madscientist14
      @madscientist14 9 หลายเดือนก่อน +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 8 หลายเดือนก่อน +41

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

    • @aBucketOfPuppies
      @aBucketOfPuppies 8 หลายเดือนก่อน +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 8 หลายเดือนก่อน +8

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

  • @Pie_Mastah
    @Pie_Mastah 8 หลายเดือนก่อน +24

    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 5 หลายเดือนก่อน +1

      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 5 หลายเดือนก่อน

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

    • @Pie_Mastah
      @Pie_Mastah 5 หลายเดือนก่อน

      @@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 5 หลายเดือนก่อน

      @@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 5 หลายเดือนก่อน +2

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

  • @GlitchedBlox
    @GlitchedBlox 7 หลายเดือนก่อน +8

    Pythagorean Theorem, my beloved.

  • @GugureSux
    @GugureSux ปีที่แล้ว +980

    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 11 หลายเดือนก่อน +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 8 หลายเดือนก่อน +57

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

    • @19Szabolcs91
      @19Szabolcs91 8 หลายเดือนก่อน +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 8 หลายเดือนก่อน +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 8 หลายเดือนก่อน

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

  • @TheGarcia122007
    @TheGarcia122007 ปีที่แล้ว +7947

    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 ปีที่แล้ว +213

      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 ปีที่แล้ว +67

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

    • @AceTheAro7
      @AceTheAro7 ปีที่แล้ว +75

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

  • @zants_
    @zants_ 8 หลายเดือนก่อน +4

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

  • @Xeno_Solarus
    @Xeno_Solarus 8 หลายเดือนก่อน +27

    Bro the Xenoblade music! Mad respect.

  • @shad-fanatic
    @shad-fanatic 8 หลายเดือนก่อน +1440

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

    • @shad-fanatic
      @shad-fanatic 8 หลายเดือนก่อน +31

      👍

    • @caldercockatoo2234
      @caldercockatoo2234 8 หลายเดือนก่อน +37

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

    • @shad-fanatic
      @shad-fanatic 8 หลายเดือนก่อน +91

      Someone else commented before, but I think they deleted it

    • @why_i_game
      @why_i_game 8 หลายเดือนก่อน +60

      @@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 8 หลายเดือนก่อน +6

      yes

  • @errantcondor9349
    @errantcondor9349 9 หลายเดือนก่อน +219

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

    • @gavinli1368
      @gavinli1368 9 หลายเดือนก่อน +38

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

    • @waltercardcollector
      @waltercardcollector 8 หลายเดือนก่อน +19

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

    • @pedrobeckup456
      @pedrobeckup456 8 หลายเดือนก่อน +13

      I love this song!!

    • @Betsy7Cat
      @Betsy7Cat 8 หลายเดือนก่อน +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 7 หลายเดือนก่อน +3

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

  • @codahighland
    @codahighland 8 หลายเดือนก่อน +4

    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.

  • @Equal-zzz
    @Equal-zzz 7 หลายเดือนก่อน +6

    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 6 หลายเดือนก่อน +1

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

  • @TheEuropeMan
    @TheEuropeMan 8 หลายเดือนก่อน +349

    Speedrunners want to know your location

  • @linksword7110
    @linksword7110 2 ปีที่แล้ว +449

    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

  • @akunbora
    @akunbora 3 หลายเดือนก่อน +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.

  • @jamaka_me_code796
    @jamaka_me_code796 หลายเดือนก่อน

    Such an elegant explanation

  • @KettleClogScratch
    @KettleClogScratch ปีที่แล้ว +21

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

  • @tiger_vii
    @tiger_vii ปีที่แล้ว +365

    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 11 หลายเดือนก่อน +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 8 หลายเดือนก่อน +12

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

    • @theoriginaldrdust
      @theoriginaldrdust 6 หลายเดือนก่อน

      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 6 หลายเดือนก่อน

      @@zaplershorts7783 were u still sleeping

  • @elowin1691
    @elowin1691 7 หลายเดือนก่อน

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

  • @diitrii
    @diitrii 6 หลายเดือนก่อน +1

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

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

  • @devmarboy4045
    @devmarboy4045 11 หลายเดือนก่อน +39

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

  • @t9foggy
    @t9foggy 7 หลายเดือนก่อน

    Undertale is a great representation of the fast diagonal movement

  • @oliverTwisTeDandCO
    @oliverTwisTeDandCO 4 หลายเดือนก่อน

    As a very new person to video game programming, im feling myself that i figured this out and fixed it in my first project 😊

  • @justaway_of_the_samurai
    @justaway_of_the_samurai 8 หลายเดือนก่อน +25

    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 8 หลายเดือนก่อน +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 8 หลายเดือนก่อน

      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 8 หลายเดือนก่อน

      @@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 8 หลายเดือนก่อน +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 7 หลายเดือนก่อน

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

  • @cdscissor
    @cdscissor 8 หลายเดือนก่อน +29

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

    • @nickpatella1525
      @nickpatella1525 7 หลายเดือนก่อน +3

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

    • @Erlisch1337
      @Erlisch1337 4 หลายเดือนก่อน +1

      @@nickpatella1525 would rather say vector math

  • @pryntik9136
    @pryntik9136 5 หลายเดือนก่อน

    Thanks ! Thanks to you I finally understood standardization 😁

  • @DodgeThatAttack
    @DodgeThatAttack 15 วันที่ผ่านมา

    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

  • @alexatedw
    @alexatedw ปีที่แล้ว +18

    Excellent use of the short content for programming.

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

  • @cjspellsfish
    @cjspellsfish หลายเดือนก่อน

    I have the subconscious urge to move diagonally in all movement games because of this phenomenon

  • @aryamaanborah7698
    @aryamaanborah7698 6 หลายเดือนก่อน

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

  • @NotLordAsshat
    @NotLordAsshat 8 หลายเดือนก่อน +21

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

  • @ndererseje1077
    @ndererseje1077 9 หลายเดือนก่อน +55

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

    • @Chronon88
      @Chronon88 8 หลายเดือนก่อน +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 7 หลายเดือนก่อน +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 7 หลายเดือนก่อน

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

  • @vulpinitemplar5036
    @vulpinitemplar5036 8 หลายเดือนก่อน

    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.

  • @UltiemeHack
    @UltiemeHack 2 หลายเดือนก่อน

    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 😢

  • @mohamedmoh5789
    @mohamedmoh5789 2 ปีที่แล้ว +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

  • @AacatNet
    @AacatNet 8 หลายเดือนก่อน +23

    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 8 หลายเดือนก่อน +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 8 หลายเดือนก่อน +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 8 หลายเดือนก่อน +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 7 หลายเดือนก่อน

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

  • @SiemJansen-x5f
    @SiemJansen-x5f 15 วันที่ผ่านมา

    Thank you! I’m creating a game with a friend for school and this really helped!

  • @juanpablosolanorojas
    @juanpablosolanorojas 7 หลายเดือนก่อน

    Damn i finally understand what normalizing a vector means

  • @MaisistkeinGemuese
    @MaisistkeinGemuese 8 หลายเดือนก่อน +6

    Oh god that soundtrack brings back so many good memories!

  • @Eddman368
    @Eddman368 9 หลายเดือนก่อน +8

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

  • @violetlavender9504
    @violetlavender9504 8 หลายเดือนก่อน +1

    I like that the character moves faster in the diagonal direction

  • @mreverything7056
    @mreverything7056 7 หลายเดือนก่อน

    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

  • @jellybon
    @jellybon 2 ปีที่แล้ว +20

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

  • @KIRBOFLURBO
    @KIRBOFLURBO 8 หลายเดือนก่อน +7

    Ah, the xenoblade music fits in so many peaceful places

  • @guimon78
    @guimon78 4 หลายเดือนก่อน

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

  • @wasquash
    @wasquash 8 หลายเดือนก่อน +2

    awesome lesson dude

  • @esben181
    @esben181 ปีที่แล้ว +4

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

  • @waltercardcollector
    @waltercardcollector 8 หลายเดือนก่อน +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)

  • @varglbargl
    @varglbargl 5 หลายเดือนก่อน

    normalizing diagonal movement alone would knock this pixel art character out of alignment with the pixel grid.

  • @yall_girl_eve
    @yall_girl_eve หลายเดือนก่อน

    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

  • @girla9480
    @girla9480 8 หลายเดือนก่อน +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 8 หลายเดือนก่อน +1

      Yeah, looks better ngl

  • @DerAndersdenker
    @DerAndersdenker 11 หลายเดือนก่อน +4

    Now i understand, why the pythagorean theorem is important.

  • @supernenechi
    @supernenechi 8 หลายเดือนก่อน

    That instantly makes entire entire movement feel so much more natural! Well done!

  • @patrikugrin2592
    @patrikugrin2592 8 หลายเดือนก่อน

    Every beginners first problem, it's quite fun to encounter these kind of problems

  • @neeha9449
    @neeha9449 8 หลายเดือนก่อน +3

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

  • @mom0367
    @mom0367 ปีที่แล้ว +12

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

  • @redtomato258
    @redtomato258 หลายเดือนก่อน

    Yooo what a game changer! Quite literally. Thank you!

  • @JorisQC
    @JorisQC 6 หลายเดือนก่อน

    One of the first things I learnt during my game development studies! 😊

  • @darkjoltgames
    @darkjoltgames 8 หลายเดือนก่อน +3

    I knew it had to be hypotenuse related

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

  • @iHashibami
    @iHashibami 5 หลายเดือนก่อน +2

    bro really say why to remember the pythagorean theorem

  • @James2210
    @James2210 5 หลายเดือนก่อน

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

  • @MinorLife10
    @MinorLife10 8 หลายเดือนก่อน +4

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

  • @ismyname_jep1394
    @ismyname_jep1394 2 ปีที่แล้ว +7

    Very informative, thank you!

  • @juhmop
    @juhmop 6 หลายเดือนก่อน

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

  • @katsureiwarui8615
    @katsureiwarui8615 8 หลายเดือนก่อน +1

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

  • @soloshottie
    @soloshottie 8 หลายเดือนก่อน +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 6 หลายเดือนก่อน +2

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

    • @mmmmmmok5292
      @mmmmmmok5292 4 หลายเดือนก่อน

      trig moment

  • @Phychologik
    @Phychologik 10 หลายเดือนก่อน +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.

  • @DustinM83
    @DustinM83 หลายเดือนก่อน

    First time a TH-cam "Short" got me to subscribe to a channel. Well done!

  • @Zei33
    @Zei33 8 หลายเดือนก่อน +1

    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.

  • @ChickenTandies
    @ChickenTandies 7 หลายเดือนก่อน +7

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

    • @miles11we
      @miles11we 5 หลายเดือนก่อน +1

      Well maybe I didn't graduate 4th grade

  • @addictionsucks8848
    @addictionsucks8848 5 หลายเดือนก่อน +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

  • @nidodson
    @nidodson 14 วันที่ผ่านมา

    It still feels faster, because the screen scrolls in both directions, instead of just one.

  • @arttukettunen5757
    @arttukettunen5757 7 หลายเดือนก่อน +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

  • @dikshantchaturvedi3099
    @dikshantchaturvedi3099 ปีที่แล้ว +5

    bro actually taught high school physics in 1 min.

    • @Narvalo_Lastar
      @Narvalo_Lastar ปีที่แล้ว +1

      not physics

    • @sanzharzaitenov5268
      @sanzharzaitenov5268 ปีที่แล้ว +1

      ​@@Narvalo_Lastarnot high school

    • @chaotickreg7024
      @chaotickreg7024 11 หลายเดือนก่อน +4

      Bro taught one lesson of pre-algebra.

    • @eVCANN
      @eVCANN 7 หลายเดือนก่อน

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

  • @alexandredesouza3692
    @alexandredesouza3692 11 หลายเดือนก่อน +12

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

  • @TheActualDP
    @TheActualDP 8 หลายเดือนก่อน

    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

  • @Greywander87
    @Greywander87 7 หลายเดือนก่อน

    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.

  • @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 2 ปีที่แล้ว

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

    • @warguy6474
      @warguy6474 9 หลายเดือนก่อน

      ​@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 8 หลายเดือนก่อน

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

    • @BoardGameMaker4108
      @BoardGameMaker4108 ปีที่แล้ว +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.

    • @BoardGameMaker4108
      @BoardGameMaker4108 ปีที่แล้ว

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

  • @Pr0t4t0
    @Pr0t4t0 7 หลายเดือนก่อน +1

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

  • @chainbladeallience
    @chainbladeallience 7 หลายเดือนก่อน

    This didn't actually explain anything but it's hard to give programming tutorials through shorts, so I applaud you for trying anyway

  • @darkgub
    @darkgub 8 หลายเดือนก่อน

    Escapists has that movement and it feels so good abusing it

  • @wiiblewobble
    @wiiblewobble 7 หลายเดือนก่อน

    That’s why speed runners move diagonally in morrowind

  • @LeSpatiocorne
    @LeSpatiocorne 15 วันที่ผ่านมา

    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.

  • @caedmonbusby4028
    @caedmonbusby4028 8 หลายเดือนก่อน

    I had never thought about normalizing vectors as moving them to the origin and shrinking them to fit. Absolutely epic.

  • @ImCrowned76
    @ImCrowned76 5 หลายเดือนก่อน +1

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

  • @Allplussomeminus
    @Allplussomeminus 3 หลายเดือนก่อน

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

  • @nikitapower947
    @nikitapower947 7 หลายเดือนก่อน

    Several Zelda games even don’t mind that acceleration

  • @raymondantonitis3936
    @raymondantonitis3936 8 หลายเดือนก่อน

    That little guy needs a diagonal movement texture!