Posted By: Tman
Quick jump code issue - 02/25/10 16:11
I have a jump code and it works great for when the player is not moving but when I am running and then jump he seems to glide and not land on his feet, anyone has ideas? Here is a portion of my code.
This is the jump portion any help is appreciated.
Code:
// adjust entity to the ground height, using a downwards trace if(c_trace(my.x,vector(my.x,my.y,my.z-5000),IGNORE_PASSABLE|IGNORE_ME) > 0) dist_down= my.z + vFeet.z - hit.z; // always place player's feet on the ground else dist_down = 0; if((dist_down > 0)) { dist_down = clamp(dist_down,100,accelerate(speed_down,-nc_gravity * time_step,0.1)); } else { //do the speed down to equal 0 so that he snaps to the ground speed_down = 0; if((dist_down + speed_down)> 0) { speed_down = - dist_down - 0; } if(key_space == 1) { jump_target = jump_height * time_step; } } if(jump_target > 0) { speed_down = (sqrt((jump_target)* nc_gravity))*time_step; jump_target -= speed_down ; }
This is the jump portion any help is appreciated.