Reputation: 1
I already tried to solve the problem of a smooth player - wall - collision so that the player slides along the wall.
I tried following:
playerBox->move();
if (playerBox->intersects(wall)) {
clearMovement();
movePlayerBoxBack();
}
But if the player touches the wall he doesn't slide... He's just stopping. (I do it separate for W, A, S and D, too.)
It only works if I set the player position back to the position of the wall he's touching. As follows:
player->move();
if (intersect) {
moveToWall();
}
But it doesn't work because for a wall, connected with another the player touches more sides and the player jumps to the corner... So it just works for a single wall...
My question is: how can I make the smooth player - wall - collision in another way which also works for a wall connected with one or more others.
Upvotes: 0
Views: 1164
Reputation: 21
You could cast a ray out from the player, see if it hits a wall. If it does collide, use the normal of your wall to make a vector that runs along the side in the direction the player is running.
Upvotes: 1