r/howdidtheycodeit • u/Masterofdos • Nov 29 '23
Answered How do they code collision/hit detection and elevation in 2D beat em ups
Apologies if lumping two questions together is an issue but I didn't want to make two posts for one and a half questions.
- First Question: Hit/Hurtboxes -
Since you can move in 6 directions in most beat-em-ups, you're basically moving in pseudo 3d space. So then, are hitboxes and hurtboxes designed the same as other games or are they made thinner due to the perspective


My assumption would be that walking up and down is done on the y axis and jumping uses something else like a "height" variable. So making boxes thinner would prevent wonky hit registration like getting clipped by someone on a different plane than you
- Second Question: elevation -
This is the main question. Some Beat em ups, like the river city games, have elevation, walls and platforms you can jump on and you can jump on some throw-able objects (boxes, trashcans). How does this work with the unique perspective and 6 direction movement. It feels like it should be more obvious but I'm stumped on how this works
View all comments
Show parent comment
2
u/RetroGamer2153 Dec 02 '23 edited Dec 02 '23
It's my Google-fu combined with a wealth of videogame history knowledge.
Edit: Be aware Birp's clone allows for jumping north /south in the Z-axis. The NES RCR only allowed jumping east / west in the X-axis.
NES RCR used a small trick to allow you to jump onto a platform. When you jump, it tests a point 1 pixel north of where you jump. If you land higher, it clips your Position.Z to match the current Position.Y. Essentially a 1:1 trade of Y & Z.
As you walk off the south edge of a platform, it auto executes a small hop, during which, they trade back some of the Position.Y to Position.Z, so you fall 2 pixels south. This allows you to avoid a looping bug (by hoping further than where the check pixel will see the north platform.).