Programming Wall Sliding | Recreating Glitches

Поділитися
Вставка
  • Опубліковано 29 вер 2023
  • I reprogrammed my collision and wall sliding from the ground up and I want to share it with you. You can port this to any language you like or just watch me code to see how it works. I will also be recreating common video game glitches to show why they happen.
    Thank you so much for subscribing and watching! I hope we can hang out again sometime.
    -Sage
    2:00 Starter file
    3:03 Vertical slide
    5:28 Horizontal slide
    7:05 Angled slide
    9:43 Sectors
    Links:
    code: github.com/3DSage/OpenGL_Wall...
    install: • Install Dev C++ and Op...
    raycaster: • Make Your Own Raycaste...
    Doom: • Let's Program Doom - P...
  • Ігри

КОМЕНТАРІ • 42

  • @EMMIR_KC
    @EMMIR_KC 9 місяців тому +16

    Awesome work, concise code, great visuals!

    • @3DSage
      @3DSage  9 місяців тому +2

      I like learning visually so I hope others do to! :)

  • @kalaherty
    @kalaherty 9 місяців тому +14

    I love the "check intersections from left" check for sectors. When I was younger, I was trying to figure out how the build engine did it, so I emailed Ken Silverman and oddly enough, he replied! He even made ASCII art in his email to explain polygon clipping. It was a nice piece of nostalgia when you mentioned it. So simple, but it blew my mind.
    Great video, creating a collision system can be a lot of fun, but such a stress when you realise a bug where it breaks. I'm quite simple, so I usually try to isolate the bug, print out the data to console and plot it on paper to locate the glitch.

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

      That's an honor that he messaged you back! I would love to post an interview with him but he is hard to contact. He definitely inspired me.
      Thank you for the compliment! Also, I just checked your channel and your game engine is looking so good! I hope you continue the project and I look forward to seeing more! :)

  • @GProgress
    @GProgress 9 місяців тому +15

    You blew my mind with the inside/outside point check. Awesome videos!

    • @3DSage
      @3DSage  9 місяців тому +1

      I know! I feel the same way! I love simple answers to what seems to be a complicated problem :)

  • @nickdance965
    @nickdance965 9 місяців тому

    Really cool stuff! Always keen to watch a 3DSage coding video :)

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

    This video was amazing, super informative.

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

    Great Video and very informative! Thank you for this video! I wonder if this diagonal Wall collision code could be modified and used to make your raycaster handle diagonal walls aswell... 🤔

    • @3DSage
      @3DSage  9 місяців тому +1

      Absolutely! Raycasters can have diagonal walls and my collision code would be very helpful!

  • @trenthm
    @trenthm 9 місяців тому

    Awesome video. Thank you!

  • @josephlandry8787
    @josephlandry8787 9 місяців тому

    Awesome video. I too have bashed my head on the keyboard for hours trying to implement wall sliding in C.

  • @lgasc
    @lgasc 9 місяців тому +1

    About those divisions by zero:
    I noticed that those only occur if a wall has a length of 0. So I would, instead of nudging the value a bit, skip such wall and, optionally, log a warning (since we usually want walls to at least have a bit of length).

    • @3DSage
      @3DSage  9 місяців тому +1

      I like it! Great idea 😎👍

  • @TanjoGalbi
    @TanjoGalbi 9 місяців тому +1

    Preventing fast speeds going past the wall is easy to do. I'll keep this to the vertical wall as it's easier to describe using one vector.
    Currently you move the player's X position by the speed amount then check if the absolute distance from the wall is below the threshold for the wall, if it is then rebound the player position to the threshold by subtracting the distance value from the threshold value and then subtract the result from the player's position.
    Examples of how your current method works:
    Let's say the wall is at X 200, the player is at X 160. The minimum distance from the wall is 32 and the normal max speed of the player is 32. The player is travelling right, so adding to the X value.
    You apply the movement of 32 to the player making the player now at 192 then calculate the distance from the wall as 8. Because that value is below the threshold of 32 you then move the player back by 24 (32-8). The player is now at 168, the minimum distance from the wall.
    But if the speed is glitched to say 80 and we now do the same: Player X + 80 = Player X now at 240. Absolute distance from the wall is now 40. Is that distance below 32? No, so no adjustment is made and the player is now glitched past the wall!
    Instead, before you move the player, take the player's absolute distance from the wall minus the threshold. Now check if that value is greater than the speed value, if it is then move the player by the speed value, otherwise move the player by the calculated distance minus the threshold value.
    Examples of how my method works:
    The player's speed is the max of 32: Player X is 160. Absolute distance (40) minus the wall threshold (32) is 8. Is that greater than 32, the speed of the the player? No, so we add the distance of 8 instead of the speed. Player X is now 168, the nearest it is allowed to the wall.
    Now let's do the same glitched 80 speed using my way: Current Player X is 160. The absolute distance from the wall minus the threshold we have 8 as before. Is that greater than the speed of 80? No, so add the the calculated distance minus the threshold to the player (160+8). Player X is now 168, the nearest it is allowed to the wall.
    Going slow, speed at 5: Player X is 160, distance minus threshold is 8 again. Is that greater than the speed value? Yes, so we add the speed value. Player X is now 165, not reached the wall yet.
    What if the speed is at the same as the distance minus threshold?: Current Player X is 160. Absolute distance minus threshold is 8. Is that greater than the speed of 8? No, so add the distance value which happens to be the same as the speed and we are at the threshold of 168.
    What if the player is already at the threshold and the speed is max?: Player X is 168. Absolute distance minus the threshold is zero. Is that greater than the speed of 32? No, so add the distance value of zero!
    It works, so now go apply that to any angle wall! 😉
    EDIT: I had a note saying your method could work if you don't use absolutes but I figured after I added the note that is does not work for moving left from the right side of the wall! LOL My method does work from either direction though. 🙂

  • @tofuninja5489
    @tofuninja5489 9 місяців тому +1

    Excuse me but WHAT at the inside outside wall thing at 10:20 . That is crazy to me. Like my mind is blown.

    • @3DSage
      @3DSage  9 місяців тому

      I know!! It's a must see to believe!

  • @dijik123
    @dijik123 9 місяців тому

    Raycast part 4 pls

  • @costelinha1867
    @costelinha1867 9 місяців тому

    Since you made an engine like that for something as old as the GBA, do you think it would be viable to make something like that for the Nintendo DS? Since it's the only retro console I have, and I have dabbled with homebrewing it yesterday.

    • @goteer10
      @goteer10 9 місяців тому +1

      If you are homebrewing, you might as well check out the gba emulator for the DS, it might not be the absolute best but it definitely works.
      Edit: Not emulator, just a game booter. DS can run GBA natively I'm dumb.

    • @costelinha1867
      @costelinha1867 9 місяців тому

      @@goteer10 I'm aware of that, it's called GBARunner2. Right now they're making GBARunner3. (Which is essential for me, since my DS does not have the GBA cart slot.) But I was trying to make for the DS specifically since it's a console I own, and therefore I can actually run the code on real hardware.

  • @jaserogers997
    @jaserogers997 8 місяців тому

    How did you learn this stuff? Must be mroe than just "I played around".

  • @ClayMurray8
    @ClayMurray8 9 місяців тому

    Isn't the angled wall check just the general case for all walls? Can't you use it for vertical and horizontal walls?

    • @3DSage
      @3DSage  9 місяців тому +1

      Could be but I am keeping optimization in mind since I'm porting this to the old GBA and someone watching might be retro programming too.

  • @longjohn7992
    @longjohn7992 9 місяців тому +1

    Doom tutorial part 3 Where >:(

    • @dijik123
      @dijik123 9 місяців тому

      Part 3 already came u need part 4

    • @longjohn7992
      @longjohn7992 9 місяців тому

      @@dijik123wdym you mean this is part 3 ????
      Could be
      But he shoulda implemented it at the end to indicate that

    • @dijik123
      @dijik123 9 місяців тому

      ​@@longjohn7992sry I thought like raycast engine 3 I was not aware of doom tutorial video

  • @artemonstrick
    @artemonstrick 9 місяців тому +1

    where doom

  • @binkbonkbones3402
    @binkbonkbones3402 9 місяців тому

    Idk if you've ever heard of a gameboy game called x, but i want to make a very low end 3d game like it for a very simple keychain game system i plan to sell for like 15 bucks
    I would love some advice for how x works, and maybe a little help. I would be more than glad to give you the vast majority of profit, because i have written a game i want to make out of pure passion and money isn't my primary goal.

  • @watercat1248
    @watercat1248 9 місяців тому

    Goin instead the collision I will be very problematic in PvP multiplayer games
    Can you imagine to play a fps game and the enemy Player to be instead the wall 🧱 or outside of the map
    I have see game in the past that this posble and this not fan for those that I do not know how go out side,
    even if you know how get out off the map it's still not fun because it's like cheating,
    even if not with console commands or therd party software.

  • @costelinha1867
    @costelinha1867 9 місяців тому

    They can be many things when they fail, entertaining, annoying, mysterious.
    My favorite however is in Celeste, where collisions straight up don't exist.

  • @LostGameDev102
    @LostGameDev102 9 місяців тому +1

    hi

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

    It's 2023. Using Dev C++ should be punished by the law, with at least 10 years sentence.

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

      You can’t tell anyone what to do on their own computer.

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

      I’m now going to learn c++ just to spite you

    • @lonesup5326
      @lonesup5326 9 місяців тому +1

      Which tool would you recommend to be used instead?

    • @CykPykMyk
      @CykPykMyk 9 місяців тому

      ​@@lonesup5326Visual Studio, or Visual Code if that's Linux. On Mac you have all three - XCode (native), VSCode, and Visual Studio as well. Dev C++ is 20 years old, underdeveloped and just bad. There were better ways at the time, and much much better ways in modern times.

    • @SianaGearz
      @SianaGearz 9 місяців тому

      @@apersomkk Oh you should probably learn C++ if you want to target embedded systems and classic game consoles.
      He meant specifically Dev-C++, an ancient gcc-centric IDE by Bloodshed written in Borland Delphi (Object Pascal), which first came out uhhh 25 years ago? The official feature list mentions something as wonderfully relevant as "CVS support", ok, CVS is indeed what people used back then; then everyone switched to SVN, because it was same thing but nicer. Then everyone switched to Git. Granted Dev-C++ did eventually gain support for at least some of these, not sure which any longer and whether git is really in there, so it is a documentation issue in part, but well it's endemic of just how crusty the project is.
      Today i would want something that is CMake-native and can divine context/insight via Clang analyser. Previously i used QTCreator for these purposes, today rather VSCode.
      But like people should use what they feel comfy with, switching tools is an overhead too, so you better be convinced it's worth it.