Hello again, all.
So I've kind of switched gears since my last game idea; this time, I'm thinking about a 2D platformer. I won't get into details, but I'm making the entire engine from scratch and I'm currently having some trouble writing an algorithm for one of the physics mechanics.
So suppose we have an object moving in a 2D plane that hits a static object (e.g. a wall) that is at an angle. Rather than bouncing, the object hits the wall and begins to slide down (or against, or whatever) the slope via deflection. If we know the velocity vector of the object before and the angle of the slope that it collides with, what is the resulting vector?
I have an idea that I can explain in words, but I can't seem to figure out how to program. What I've done on paper is put the object's incident vector's tip at the collision point on the slope. I then extend this vector past (underneath) the slope to find the hypotenuse of a right triangle. The legs are parallel and perpendicular to the face of the slope. the leg of the triangle that's parallel to the slope is obviously the resultant vector of the object, and it moves in that direction to slide down the slope.
The problem is: What is the formula for that?
I've already done bouncing off slopes, but this in comparison is much more complex of a problem. I want to use this to create fluid motion when the PC is sliding up and down slopes.
If you want to see my vector classes, I can post them, but at the moment, I'm just asking for help on the equation.
(Side note: Due to the way I'm planning to implement these slopes, I don't have to worry about ray casting or anything, as the game will be tile-based and each of the slope tiles will have angle variables that can be accessed when colliding with them.)