Currently, I want my player to build up speed while wallrunning until a certain time finishes, perhaps 3 seconds of building up y velocity then he starts to slowly descend, does anyone know how to do that? Take care everyone.
If I’m reading this correctly, you’re looking to have a very similar wallrun to this?
In the real world, this is done by having a starting positive Y velocity and a negative Y acceleration, that is, the vertical speed starts out high and is decreased by a constant amount per unit time. In free fall, this is gravity (falling 9.8 meters per second faster, every second). This curve forms a perfect arc.
In a game, you may or may not want to have things feel floatier than this, making the rise take more time than the fall, so the player has more time to think and adjust. If you want to do this, it can be done in a couple of ways. One way would be to have the y velocity decrease per unit time by a small constant at first, then a bigger constant once the y velocity reaches a certain value, like 0. Another way would be to use jerk (y^3) instead of acceleration (y^2) and reduce the velocity by the square of a unit time difference since starting the wallrun, if that makes sense.
To implement this, you probably want to set the Y velocity on the first frame of the wallrun to whatever positive value you test that feels right, then have a constant Y velocity to reduce per second (say, float startingWallrunYVelocity =3 to start out testing with). Then subtract that while the wallrun is going on in each update.
For Update(): reduce the y velocity by startingWallrunYVelocityTime.deltaTime.
For FixedUpdate(): reduce the y velocity by startingWallrunYVelocityTime.fixedDeltaTime