Works! Thank you 3run, you helped me a lot.

I have one more question, maybe you can help me because I download this gravity code from your page. How I can in this code reduce the height of the edge that the player can climb? For example, I do not use stairs in the game, but only flat surfaces. Now it happens to me that a player can climb on smaller crate model, at the place where he should stop, and there player must jump. This fast z moving looks really bad in game.
Should I need to use c_trace to detect if there is a block in front or there is some better solution? Example, now player can climb on crate where maximum z is 30, I want to reduce it on 5 or less.