"Slide Against Wall" - collision detection formula

แชร์
ฝัง
  • เผยแพร่เมื่อ 11 ธ.ค. 2024

ความคิดเห็น • 17

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

    Unbelievably helpful, saved me from having to re-learn vector math for my game. Thanks so much!

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

    Your video was by far the best explanation I have found! Thank you so much!

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

    Thank you so much for the great explanation in a simple way.

  • @_yannis2707
    @_yannis2707 3 ปีที่แล้ว +2

    Thank you! This explanation really helped me.

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

    Thank you, this is just what I needed!

  • @420lehtoo
    @420lehtoo ปีที่แล้ว

    I got really desperate thank you

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

    It's called projection, you're basically projecting the move direction into the wall's normal, this will produce a new vector that slides perfectly along the wall plane.

  • @АлександрКалак-й5к
    @АлександрКалак-й5к ปีที่แล้ว

    thanks, now it looks really easy

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

    But how do I know on collision which normal of the wall I have to use? I have a function that tells me a when a collision with the wall is happening, but not from which side. I want to return the correct normal vector when I'm colliding with the wall, but how do I distinguish between them?

    • @HelloWorldCode
      @HelloWorldCode  4 ปีที่แล้ว

      Very good question!
      For this you would need some other math of course.
      Here is an answer for you:
      gamedev.stackexchange.com/questions/12875/how-do-i-determine-the-collision-normal-in-an-axis-aligned-bounding-box-collisio

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

      @@HelloWorldCode Thx for your reply. I got it working using this awesome picture:
      phstudios.cachefly.net/GameAlgorithms/2D-Rectangle-Collision-Normal-Sides.png
      pretty proud to now have wrote my own wall sliding collisions =)
      took me a day

  • @ariseyhun2085
    @ariseyhun2085 2 ปีที่แล้ว

    Extremely helpful, thank you.
    One problem I have is sometimes the player gets stuck due to rounding errors. For example, with a constant Y velocity for gravity, the player can get stuck.
    Do you know how I could add a `0.01` buffer to prevent the player getting so close to the wall/ground?

  • @twardy9548
    @twardy9548 2 ปีที่แล้ว

    Thank you so much

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

    Hey, thank you A LOT! I tried do same thing with vector projection but I failed miserably

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

      Isn't vector projection kind of the same thing? Correct me if I'm wrong, I don't know much about that stuff.

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

      @@_yannis2707 I can't quite remember, because it was a year ago or something. But I do remember that vector projection caused clipping glitches

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

      @@barrettkepler7618 Oh, yeah sorry ^^