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.
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?
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
@@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
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?
Unbelievably helpful, saved me from having to re-learn vector math for my game. Thanks so much!
Your video was by far the best explanation I have found! Thank you so much!
Thank you so much for the great explanation in a simple way.
Thank you! This explanation really helped me.
Thank you, this is just what I needed!
I got really desperate thank you
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.
thanks, now it looks really easy
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?
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
@@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
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?
Thank you so much
Hey, thank you A LOT! I tried do same thing with vector projection but I failed miserably
Isn't vector projection kind of the same thing? Correct me if I'm wrong, I don't know much about that stuff.
@@_yannis2707 I can't quite remember, because it was a year ago or something. But I do remember that vector projection caused clipping glitches
@@barrettkepler7618 Oh, yeah sorry ^^