Multiple planes on collision detection sliding
I've got working collision detection and "sliding" response to it. Everything is working just fine, but when there is only one wall to collide (I'm ignoring collisions with terrain yet). When there is second wall, problems begin to emerge.
Following picture demonstrates what I'm talking about.
Part A is the situation, in which everything works fine, the character (circle) simply slides along it.
What I need to achieve is when we reach the corner, the character should stop, as there is nowhere to go, but instead it ignores the first wall, and moves through it.
Here's simplified code of my move function:
Collision is simply struct that contains colliding wall's normal, and collision point.
void ObjMobile::Move(glm::vec3 velocity)
for (Collision &c : collisions)
velocity -= coll.Normal() * glm::dot(velocity, coll.Normal());
position += velocity;
So, putting everything short: I want to prevent movement against all the walls, when there are multiple collisions. What am I missing in my code?