Тёмный

How to fix your diagonal movement! 

Challacade
Подписаться 78 тыс.
Просмотров 2,8 млн
50% 1

Diagonal movement may be easy to implement, but you might want to consider normalizing your vectors.
#gamedev #shorts

Опубликовано:

 

1 окт 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 1,9 тыс.   
@heartofdawnlight
@heartofdawnlight 10 месяцев назад
speedrunners hate this one programming technique
@-Yello-
@-Yello- 9 месяцев назад
I was thinkin the same thing lol
@729MendicantTide
@729MendicantTide 9 месяцев назад
Goldeneye players too
@ollllj
@ollllj 9 месяцев назад
we need a list of 3d games, that fail to normalize some movement vectors.
@danolantern6030
@danolantern6030 9 месяцев назад
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 9 месяцев назад
​​@@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
@Casual330
@Casual330 Месяц назад
Running in zig-zags never made more sense
@motc8238
@motc8238 Месяц назад
let's say you're going right, whether you go up or down as you go right, in this scenario you'd still only move right at the same speed.
@SalimShahdiOff
@SalimShahdiOff 23 дня назад
Still doesn't make send
@radialmachinery9947
@radialmachinery9947 22 дня назад
​@@motc8238But if you want to just say go forward if you keep holding right you would end up completely wrong
@coco13579
@coco13579 17 дней назад
​@@motc8238 actually, you'd be going a lot slower becaused the horizontal speed is less than the total speed, instead of being equal like if you went straight
@trifortay
@trifortay 11 дней назад
running in a zigzag wouldn't increase you're vertical velocity.
@rory8182
@rory8182 10 месяцев назад
This is why they move diagonally in original Doom speedruns
@Kushibunny
@Kushibunny 9 месяцев назад
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 9 месяцев назад
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 9 месяцев назад
And Goldeneye
@threeco2350
@threeco2350 9 месяцев назад
​@@platinumfactoryes, a good example of the movement shown in this video would be diablo 1.
@TF2Starlight
@TF2Starlight 9 месяцев назад
@@platinumfactoryea you can run along a wall and run faster…
@Neodx2
@Neodx2 9 месяцев назад
"When will we ever use Pythagoras in real life?" Clarification: this comment is mocking people who think this
@DasOrange
@DasOrange 6 месяцев назад
Pythagorian theorem is one of my most used formulas. Trigonometry is so useful.
@MagikalKrabical
@MagikalKrabical 6 месяцев назад
Pythagoras is the most used theorem outside of school and direct mathematics istg
@jibstacking
@jibstacking 6 месяцев назад
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 5 месяцев назад
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_ 5 месяцев назад
He explained it explicitly trying to fit it to use that math technique. Still useless lol.
@thelred-ph3lq
@thelred-ph3lq Год назад
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 Год назад
Remember, you don’t need to outrun the monster. Just outrun your friends!
@ChronoNewton
@ChronoNewton Год назад
lmao🤣🤣
@ultra-doggofn9788
@ultra-doggofn9788 10 месяцев назад
😂😂
@GunSpyEnthusiast
@GunSpyEnthusiast 9 месяцев назад
@@meteylmaz4366 note to self, run at an angle which you can run directly to your friend to clothesline them, whilst moving diagonally.
@Sjorsje
@Sjorsje 9 месяцев назад
The World is not Enough on N64 in a nutshell
@MrSirSquishy
@MrSirSquishy 5 месяцев назад
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 3 месяца назад
This is such an important thing. So many devs lost this mindset.
@mchlkpng
@mchlkpng 3 месяца назад
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 2 месяца назад
​@@mchlkpngBecause you basically are. You're not going forwards as fast, nor are you moving to the side as fast.
@mchlkpng
@mchlkpng 2 месяца назад
@@anonymousapproximation8549 true
@marcxworld5708
@marcxworld5708 Месяц назад
Nah its not better lol
@glltyt
@glltyt 2 года назад
This is the first time I've ever understood the relation between the game math and the result. Thank you so much.
@ravihlb
@ravihlb 9 месяцев назад
Same!
@hikari1690
@hikari1690 9 месяцев назад
I just clicky cause I wanty. Sides, could use polar coordinates instead of this Kardashian coordinates and save some computing power 🤣
9 месяцев назад
​@@hikari1690That would work, but wouldn't save any computing power.
@squishyushi
@squishyushi 9 месяцев назад
Big brain
@clumsypanda7433
@clumsypanda7433 9 месяцев назад
​@@hikari1690Cartesian*. Kardashian coordinates would be used to measure amount of plastic in a bimbo
@pinkie723
@pinkie723 9 месяцев назад
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 6 месяцев назад
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 6 месяцев назад
i dont think godbridging exists in topdown pixel games though
@raven-a
@raven-a 6 месяцев назад
​​@@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 5 месяцев назад
​@@raven-aanother solution: make the character's minimal speed X pixels/frame and round normalized diagonal velocity to nearest integer.
@EphemeralPseudonym
@EphemeralPseudonym 5 месяцев назад
it's extra math, normalizing the vector isn't as simple as dividing by a specific factor if the game allows multiple movement speeds
@kennethha8173
@kennethha8173 11 месяцев назад
"When are we ever going to need to use the Pythagoras theorem?"
@19Szabolcs91
@19Szabolcs91 9 месяцев назад
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 9 месяцев назад
​@@19Szabolcs91Measuring stuff uses trig more than pythagoras. It comes in handy for setting up perpendiculars though.
@mohsinuddin7049
@mohsinuddin7049 9 месяцев назад
“You won’t, but the smarter kids will.”
@DimT670
@DimT670 9 месяцев назад
​@@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 9 месяцев назад
My dad in school: "Fuck this algebra and geometry shit I'll never use it" My dad at work: is a carpenter
@Pie_Mastah
@Pie_Mastah 9 месяцев назад
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 7 месяцев назад
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 7 месяцев назад
I think usually characters move more than one pixel per frame.
@Pie_Mastah
@Pie_Mastah 7 месяцев назад
@@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 7 месяцев назад
@@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 7 месяцев назад
@@michawhite7613 only noticeable when in a pixel art style, when 8-9 pixels is like half the size of the player
@GugureSux
@GugureSux Год назад
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 Год назад
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 9 месяцев назад
Looking down to run the game at a constant 60fps is another speedrun strat for that game.
@19Szabolcs91
@19Szabolcs91 9 месяцев назад
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 9 месяцев назад
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 9 месяцев назад
​@@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
@GlitchedBlox
@GlitchedBlox 8 месяцев назад
Pythagorean Theorem, my beloved.
@TheGarcia122007
@TheGarcia122007 Год назад
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 Год назад
Go for engineering studies and oh boy you're going to need them a lot :D
@uncensored393
@uncensored393 Год назад
​@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 Год назад
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 Год назад
For everyday life? Probably not, but math is the heart engineering, science and coding imo
@AceTheAro7
@AceTheAro7 Год назад
I must say out of everything, Pythagorean theorem is the most used formula ever
@Xeno_Solarus
@Xeno_Solarus 9 месяцев назад
Bro the Xenoblade music! Mad respect.
@raya-fantasia
@raya-fantasia 10 месяцев назад
As the artist of an indie team, I really want that guy to have diagonal animations
@raya-fantasia
@raya-fantasia 9 месяцев назад
👍
@caldercockatoo2234
@caldercockatoo2234 9 месяцев назад
@@raya-fantasiaWhy’d you reply to your one comment?
@raya-fantasia
@raya-fantasia 9 месяцев назад
Someone else commented before, but I think they deleted it
@why_i_game
@why_i_game 9 месяцев назад
@@raya-fantasia 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?"
@raya-fantasia
@raya-fantasia 9 месяцев назад
yes
@ImCrowned76
@ImCrowned76 6 месяцев назад
Of all the math I’ve learned until now, the pythagorean theorem seems to be the only one that keeps popping up as useful
@tradermann
@tradermann 2 дня назад
wait until you learn some trigonometry
@stellar7933
@stellar7933 Год назад
Love how algebra actually becomes so helpful when you get into programming
@janpapai9205
@janpapai9205 10 месяцев назад
Its kinda more linear geometrics then algebra bc the formula is about a triangle and its sides but nevermind
@madscientist14
@madscientist14 10 месяцев назад
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 10 месяцев назад
Welcome to engineering - where we actually use the maths we were taught in school
@aBucketOfPuppies
@aBucketOfPuppies 9 месяцев назад
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 9 месяцев назад
especially when you take linear algebra and it’s basically fundamental to computing graphics and games
@Equal-zzz
@Equal-zzz 9 месяцев назад
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 7 месяцев назад
divide the speed by sqrt2 and put it in both x and y of movement vector
@errantcondor9349
@errantcondor9349 10 месяцев назад
I could swear I heard Colony 9 in the background. I love you.
@gavinli1368
@gavinli1368 10 месяцев назад
Yeah!!! Xenoblade OST fans! Escoecially the night time theme!!!
@waltercardcollector
@waltercardcollector 9 месяцев назад
Yess! Colony 9 night music is one of my favorite video game music pieces of all time.
@pedrobeckup456
@pedrobeckup456 9 месяцев назад
I love this song!!
@Betsy7Cat
@Betsy7Cat 9 месяцев назад
@@gavinli1368I recognized it right away bc it’s one of like 5 songs from the game I use to fall asleep lmao
@Sharklady594
@Sharklady594 8 месяцев назад
I immediately knew it was a xenoblade song I just didn’t know which one, thank you
@Krzztl
@Krzztl 2 месяца назад
Oh so THAT’s how you use the pythagorean theorem
@TheEuropeMan
@TheEuropeMan 9 месяцев назад
Speedrunners want to know your location
@MinorLife10
@MinorLife10 9 месяцев назад
I swear to god, if JRPGs fix this "bug", that will make me hate them even more
@tiger_vii
@tiger_vii Год назад
I can't believe I fell asleep during maths classes..... Damn it!
@zaplershorts7783
@zaplershorts7783 Год назад
Ik I’m late at answering but, I did too 😅
@erikblaas5826
@erikblaas5826 Год назад
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 10 месяцев назад
nah its not ur fault, they make it as boring as one could imagine
@theoriginaldrdust
@theoriginaldrdust 8 месяцев назад
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 8 месяцев назад
@@zaplershorts7783 were u still sleeping
@codahighland
@codahighland 9 месяцев назад
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.
@jadenh_gamedev
@jadenh_gamedev Год назад
I will refer to this video every time I make a top down game. Thanks so much! Also appreciate the Xenoblade music.
@EyNickSee
@EyNickSee Месяц назад
I'm learning gamedev/programming, and this helps understand the use of "normalize" so much more clearly now. Thank you
@linksword7110
@linksword7110 2 года назад
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 года назад
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 года назад
where shoul i copy it? in fuction load or update
@pyrytheburger3869
@pyrytheburger3869 2 года назад
@@alessioturco953 update probably
@linksword7110
@linksword7110 2 года назад
i would recommend learning how normalization works with math.
@tofame4291
@tofame4291 Год назад
@@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
@iHashibami
@iHashibami 6 месяцев назад
bro really say why to remember the pythagorean theorem
@devmarboy4045
@devmarboy4045 Год назад
no wonder my game character felt a little fast when moving diagonally thank you so much I forgot about this lol
@zants_
@zants_ 9 месяцев назад
I never realized why diagonal movement was so uncanny, this was so helpful
@PieDivide
@PieDivide Год назад
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
@Torbulous
@Torbulous Месяц назад
I knew this video was going to say normalize it. Everyone tells you to normalize the vector. What this does is get rig of lower analog input since normalizing vectors keeps vectors at a distance of 1. You should instead, limit the length of the vector. It's called different things in different game engines. I think Unity calls it "Vector magnitude". Godot and Unreal call it "Vector length". If you limit the vector to 1, then maintain analog input so you can move slower. I get not every game needs this, but it doesn't really matter. You'd be surprise how much better it feels and controller players will appreciate it.
@KettleClogScratch
@KettleClogScratch Год назад
I'm working on a top down adventure game and this actually helped fix my diagonal movenment. Thanks!
@brodyfishel5579
@brodyfishel5579 Год назад
Which engine are you using?
@gamek9992
@gamek9992 8 месяцев назад
You can just divide speed of a player by sqrt(2) while he is moving in 2 directions at once what is eazy to detect by checking pressed keys and as a result his diagonal movement will be the same as straight.
@justenoughrandomness8989
@justenoughrandomness8989 2 дня назад
easiest solution and it works perfectly, any other amount of directions and there is no need to divide the speed (didn't see that the comment is 8 months old)
@ndererseje1077
@ndererseje1077 10 месяцев назад
some games intentionally make it a little faster so it doesn’t feel too slow
@Chronon88
@Chronon88 9 месяцев назад
Yeah. That sounds like the way to do it. Just make it like this then add 10% and it might feel better.
@eVCANN
@eVCANN 9 месяцев назад
Yeah, I came back to this video after playing Stardew Valley for the first time, vertical movement is painful in that game
@georgelionon9050
@georgelionon9050 8 месяцев назад
lol, this so much like that without coyote time players feel betrayed and claim your controls are unresponsive..
@OBLIMMONSTER
@OBLIMMONSTER 8 месяцев назад
Lets say we move 1 pixel per frame Me *turns off v sync* No hate btw awesome video
@chaos2232
@chaos2232 3 месяца назад
Me : *Graduate highschool and never have to worry about math again* My math teacher :
@justaway_of_the_samurai
@justaway_of_the_samurai 9 месяцев назад
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 9 месяцев назад
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 9 месяцев назад
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 9 месяцев назад
@@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 9 месяцев назад
@@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 9 месяцев назад
This very much applies to 4D games, where the ground is 3D, meaning you need to normalize a 3D movement vector.
@wildfire9280
@wildfire9280 9 месяцев назад
Stop making math teachers right about future uses of math.
@cdscissor
@cdscissor 9 месяцев назад
So that's why arcs are so important. They keep the distance travelled consistent no matter what direction you go!
@nickpatella1525
@nickpatella1525 9 месяцев назад
I wouldn't say "arcs". Rather "the unit circle", the thing they taught in trigonometry class.
@Erlisch1337
@Erlisch1337 5 месяцев назад
@@nickpatella1525 would rather say vector math
@Will_Forge
@Will_Forge 9 месяцев назад
This is the first time I have ever heard someone so heavily misuse the word "pixel". That is not a pixel. That's is a grid square each made up of many pixels.
@AacatNet
@AacatNet 10 месяцев назад
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 9 месяцев назад
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 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 9 месяцев назад
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 9 месяцев назад
@@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
@le9038
@le9038 15 дней назад
Speed of motion should not be reliant on frame speed. Running the game on better hardware will result in incorrect and improper motion. This is why the turbo button exists.
@alexatedw
@alexatedw Год назад
Excellent use of the short content for programming.
@minimalgrammar1276
@minimalgrammar1276 9 месяцев назад
I'm pretty sure Undertale fucked this up LMAO
@jellybon
@jellybon 2 года назад
Thank you for this ☺️ I bought your Udemy course last weekend and plan to follow it on the weekends
@grzyb11
@grzyb11 9 месяцев назад
just a slightly more accurate thing: the movement speed is the square root of 2 which is like 1.41421 and so on and so on
@mohamedmoh5789
@mohamedmoh5789 2 года назад
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
@iofs3338
@iofs3338 9 месяцев назад
I love celebrating the birth of Jesus the Christ
@Eddman368
@Eddman368 10 месяцев назад
This also explains why in older games like Doom you move faster diagonally
@HINACP
@HINACP 5 месяцев назад
It's a good idea to fix this in any games BUT TOPDOWN RPGS! I'M GONNA DO SOME THINGS THAT EVEN DUOLINGO WOULDN'T DARE TO EVERY PERSON THAT DOES THIS BEGINNING BY YOU! In more serious terms, doing this will only be annoying. At no point will this be used as you still go as fast as going straight since you can't do it while being straight unlike in fps where you can move your camera 45°. Is players only use it to wiggle while walking long distances because it FEELS faster but it isn't.
@HINACP
@HINACP 5 месяцев назад
@PirateSoftware . That's the only bad thing that I ever found in Heartbound.
@waltercardcollector
@waltercardcollector 9 месяцев назад
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)
@RouxlsKaardOfficial
@RouxlsKaardOfficial 9 месяцев назад
Square diagonals are square root of 2? This is why Hexagon is bestagon.
@KIRBOFLURBO
@KIRBOFLURBO 10 месяцев назад
Ah, the xenoblade music fits in so many peaceful places
@Aerialyn
@Aerialyn 8 месяцев назад
Luna Game 3D has this error which helps immensely on speedruns
@MaisistkeinGemuese
@MaisistkeinGemuese 9 месяцев назад
Oh god that soundtrack brings back so many good memories!
@Pr0t4t0
@Pr0t4t0 8 месяцев назад
This is why vectoring exists in Super Mario Odyssey and 3D World + Bowser’s Fury speedruns
@DerAndersdenker
@DerAndersdenker Год назад
Now i understand, why the pythagorean theorem is important.
@TuriGamer
@TuriGamer 8 месяцев назад
Man spends the entire short telling us what the problem is but not how to actually fix it hahaha
@Phychologik
@Phychologik Год назад
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.
@bland9876
@bland9876 9 месяцев назад
There are some video game controllers that have a bad d-pad such that when you're trying to go left or right your character will sometimes go diagonal as well making him walk like he's drunk now for those that know the history of the d-pad they would expect Nintendo not to be one of those people that has a d-pad like this but currently on the Nintendo Switch pro controller they do. I don't get how they of all people are the ones that screwed this up. For some reason I don't remember the Wii U having this issue except for specifically Ittle Dew. I don't know how a single game can have that issue when all the others don't and yet diagonals worked perfectly fine but there you go.
@esben181
@esben181 Год назад
I've never noticed that the diagonal movement in my prototype was like this. Thanks!
@KoraOSRS
@KoraOSRS 9 месяцев назад
Doesn’t that make the grid screwy though? Sorry I don’t know the first thing about this, my gut instinct just tells me there would be an issue with keeping consistent grid coordinates if the diagonal is shortened
@ismyname_jep1394
@ismyname_jep1394 2 года назад
Very informative, thank you!
@GreenLantern814
@GreenLantern814 9 месяцев назад
Wish the Pokemon company had paid attention to this!! I'm so sick of seeing "Move faster going diagonally" listed as a cheat code!!!
@mom0367
@mom0367 Год назад
Game dev is the only reason I'm genuinely interested in math class now.
@pipik7457
@pipik7457 9 месяцев назад
This is actually the case in Diablo 1 and Diablo 2! I was playing it and noticed this immediately. I wonder if they left it in on purpose?
@ChickenTandies
@ChickenTandies 9 месяцев назад
How anyone who goes through school and college not knowing this already baffles me. It’s vectors 101
@miles11we
@miles11we 7 месяцев назад
Well maybe I didn't graduate 4th grade
@DefenDefault4
@DefenDefault4 9 месяцев назад
This also happens in Minecaft, it's faster when diagonal.
@CountDooku420
@CountDooku420 8 месяцев назад
I'm pretty sure that's not how Minecraft works. Minecraft's movement system is the same as any other 3D game, so going at a 45 degree angle from the grid won't be faster. In Minecraft, if you move at a 45 degree angle, you're most likely facing in that direction. So you're only holding one key. Hence, it only moves you at the normal speed.
@soloshottie
@soloshottie 9 месяцев назад
fun fact: controller sticks have this kind of "normalizing" built in. since it can only rotate in a circle, it can only read X and Y axis inputs within that circle, meaning all edges of the stick are a 1 input, in some combination of X and Y
@nidbahn
@nidbahn 7 месяцев назад
this made me realize that sin²x+cos²x=1 also comes from the pythagorean theorem
@mmmmmmok5292
@mmmmmmok5292 5 месяцев назад
trig moment
@kosuken
@kosuken 9 месяцев назад
Im not fixing my game this way because speed runners
@gravestron9695
@gravestron9695 2 года назад
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 года назад
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 10 месяцев назад
​@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 9 месяцев назад
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)
@szabotudor
@szabotudor 4 месяца назад
I thought this was going to be about fixing diagonal movement in pixelart games, where the low resolution makes the camera movement shaky
@addictionsucks8848
@addictionsucks8848 7 месяцев назад
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
@coin777
@coin777 9 месяцев назад
how can you move 0,7 of a pixel if a pixel is the smallest distance you can move? physicist hate this trick.
@lonkus1290
@lonkus1290 9 месяцев назад
Subpixels are a thing
@akunbora
@akunbora 5 месяцев назад
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.
@lillii9119
@lillii9119 6 месяцев назад
I don't really understand who would not know how to solve that but still have the programming skills to normalise a vector, but ok
@arctic8137
@arctic8137 Год назад
yeah i get that, BUT HOW DO I ACTUALLY ADD THIS!!!!
@ckorp666
@ckorp666 Год назад
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 Год назад
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?
@arttukettunen5757
@arttukettunen5757 8 месяцев назад
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 Год назад
bro actually taught high school physics in 1 min.
@Narvalo_Lastar
@Narvalo_Lastar Год назад
not physics
@sanzharzaitenov5268
@sanzharzaitenov5268 Год назад
​@@Narvalo_Lastarnot high school
@chaotickreg7024
@chaotickreg7024 Год назад
Bro taught one lesson of pre-algebra.
@eVCANN
@eVCANN 9 месяцев назад
Yeah because he teaches it assuming that everyone here understands it, it’s more like a refresher
@openheimr
@openheimr 5 месяцев назад
it sucks when everything in the game is placed on a grid but the character can move freely so lining things up is confusing
@ElFastasXD
@ElFastasXD 6 месяцев назад
Wow, 2D zelda games also reduces diagonal speed
@justsumrandom3882
@justsumrandom3882 2 месяца назад
ISTG SOME GAMES DONT NORMALISE AND THAT IS WHY YOU CAN SWEAR MOVING DIAGONALLY IS FASTER!!!
@Grassplant2012
@Grassplant2012 9 месяцев назад
I don't care about stupid calculus stuff💀
@klegos
@klegos 8 месяцев назад
Doesn’t anyone realize that it taking advantage of such glitches is situational?
@klegos
@klegos 8 месяцев назад
I use the trig functions and directional variables to achieve the fixed effect.
@nathankellogg2640
@nathankellogg2640 9 месяцев назад
This always bothered me. It's even in Stardew Valley
@itsyusufcraft4674
@itsyusufcraft4674 9 месяцев назад
So to do that do I just make it so it will go 0.4 in the other direction
@ClodsireBcuzYes
@ClodsireBcuzYes 5 месяцев назад
the one and only time that will come in handy
@Jassi-WRLD
@Jassi-WRLD Месяц назад
but why according to the theory it should take more time? 🧐
@Zei33
@Zei33 9 месяцев назад
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.
@grigorov_srg
@grigorov_srg 8 месяцев назад
Short answer: use normalized vector for direction
@ProCoder2040
@ProCoder2040 6 месяцев назад
I love the fast diagonal tho :(
@Garfield_Minecraft
@Garfield_Minecraft 7 месяцев назад
only 40% make that a feature
@teroblepuns
@teroblepuns 9 месяцев назад
I kid you not, we had this in math class last week
@TheMusicTheorists18
@TheMusicTheorists18 9 месяцев назад
Straffing is a speedrunning strategy. Y get rid of it
@nuclear7622
@nuclear7622 7 месяцев назад
How do you ensure you don’t get a zero division error when dividing by the magnitude of your vector?
@ExodiumTM
@ExodiumTM 7 месяцев назад
If the norm is zero, the player's not moving in the first place. Not really doing any game programming, but why not just calculate movement whenever there's a movement input?, like: if (inputX != 0 || inputY != 0) { norm = sqrt(inputX^2 + inputY^2); else { norm = 1; } moveVec = (inputX + inputY)/norm; (pseudocode cause I can't bother)
@nuclear7622
@nuclear7622 7 месяцев назад
@@ExodiumTM I’m not working on a project atm but the reason I didn’t want to do this is because I don’t want to do an if check every frame or every tick if there is a natural workaround. I’m not sure if one is possible though
@ExodiumTM
@ExodiumTM 7 месяцев назад
@@nuclear7622 to be fair, a single if statement is pretty irrelevant every frame, when other mechanics will inevitably be far more resource-consuming. But you're right, optimally you'd want a faster workaround
@bepisgamer
@bepisgamer 8 месяцев назад
i can’t imagine how proud of himself he is after using the pythagorean theorem in real life
@RandomDude1487
@RandomDude1487 4 месяца назад
Or leave it for speed runners
@DodgeThatAttack
@DodgeThatAttack Месяц назад
quick note: normalising the vector will also INCREASE its value to 1 if you try to only move slightly. You want to normalise _the direction_ and apply movement speed separately - you might run into unexpected behaviours otherwise
Далее
I Paid Fiverr Game Developers to Make the Same Game
10:25
I Spent 2,000 Hours Using Scratch
13:59
Просмотров 608 тыс.
Учёные из Тринидад и Тобаго
00:23
Вопрос Ребром - Серго
43:16
Просмотров 1,4 млн
The Internet Played My Game (and it did not go well)
9:27
Every Game Engine Explained In 9 Minutes (Part 1)
9:10
How Much Money my Mobile Game Made (After 1 month)
5:24
Balatro's 'Cursed' Design Problem
13:31
Просмотров 692 тыс.
I Made the Same Game in 8 Engines
12:34
Просмотров 4,1 млн
If You Can't Make Games After This Video, Give Up
4:37
We made Vampire Survivors BUT in 10 Lines of Code
7:08
Creating SMART enemies from scratch! | Devlog
5:40
Просмотров 332 тыс.
Why Slopes are Shockingly Difficult for Indie Game Devs
17:20