Wall grabbing issue

Hello! I want to make a system similar to those mario games, where you can grab onto a wall and slide down it slowly and jump off it. To achieve that, I wanted set the player’s walkspeed to 0 so that they are unable to move towards and away from the wall. However, I also want the player to be able to slide left and right, and detach away from the wall.

So from the picture above, the circle’s circumference just represents the direction that the player can go to (im using humanoid.movedirection to check which direction the player wants to go). For example, if the player wants to move in the direction of the grey arrow, the value of X determines how fast the player would move left and right (i plan on manually setting the player’s position by updating it every frame, may not be a good idea).

However, I also want the player to stop grabbing the wall when their movedirection is facing the blue part of the circle.

Im not really good at the math and physics of such things, so help would be appreciated :slight_smile:

Sorry if the way I explained is not clear, its a bit difficult for me to explain, if you need details pls ask :pray:

Edit: I solved the problem about the player stopping the wall grab when facing the blue part, but I havent solved the moving left and right issue

1 Like

the red is the wall grab part, the blue is the move away from wall part

if you have an angle t, and the player rotation p then the blue part is the area between two lines angled at t+p and 180+t+p

and the angle of the move direction is probably atan2(moveDirection.z, moveDirection.x) (might be shifted)

so if the move angle is more than the angle of the first line and less than the angle of the second line, then the player is trying to stop grabbing. Otherwise, they are still trying to grab

And for moving left and right you can move based on the rightvector of the wall part
maybe when the movedirection aligns with the right/left vector of the wall, using cosine similarity, or maybe just when they press w/s or a/d