-
Автор темы
- #1
The head bounce feature checks if the player is alive, not on the ground, and not on a ladder or in noclip mode. If any of these checks fail, the function returns. Next, the function checks which movement direction the player is pressing (forward, back, left, or right) and sets the wishdir vector accordingly. If the player is not pressing any of these keys, the function returns.
The head bounce then performs a trace (a line check) from the player's current position to the wishdir position and stores the result in a trace_t object. If the trace fraction (the fraction of the distance between the start and end positions that the trace traveled before hitting something) is less than 1 and the normal vector of the trace plane (the plane formed by the surface that was hit) has a z-value of 0, the function performs another trace from the player's position to a position based on the normal vector of the first trace's plane. If the planes formed by these two traces are different, the function calculates the angle to the wall and the player's velocity and modifies the player's movement input accordingly.
The head bounce then performs a trace (a line check) from the player's current position to the wishdir position and stores the result in a trace_t object. If the trace fraction (the fraction of the distance between the start and end positions that the trace traveled before hitting something) is less than 1 and the normal vector of the trace plane (the plane formed by the surface that was hit) has a z-value of 0, the function performs another trace from the player's position to a position based on the normal vector of the first trace's plane. If the planes formed by these two traces are different, the function calculates the angle to the wall and the player's velocity and modifies the player's movement input accordingly.