How to fix your diagonal movement!

preview_player
Показать описание
Diagonal movement may be easy to implement, but you might want to consider normalizing your vectors.

#gamedev #shorts
Рекомендации по теме
Комментарии
Автор

speedrunners hate this one programming technique

heartofdawnlight
Автор

This is why they move diagonally in original Doom speedruns

rory
Автор

"When will we ever use Pythagoras in real life?"

Clarification: this comment is mocking people who think this

Neodel
Автор

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

pinkie
Автор

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

thelred-phlq
Автор

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

glltyt
Автор

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.

MrSirSquishy
Автор

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

Pie_Mastah
Автор

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

kennethha
Автор

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 😅

TheGarcia
Автор

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.

GugureSux
Автор

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

stellar
Автор

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.

equal
Автор

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

neeha
Автор

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

shad-fanatic
Автор

Speedrunners want to know your location

TheEuropeMan
Автор

First time a YouTube "Short" got me to subscribe to a channel. Well done!

DustinM
Автор

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.

codahighland
Автор

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

errantcondor
Автор

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

linksword