Sign in to follow this  

Corner Slide-correction too fast.

Recommended Posts

i am creating a FPS game. If the player is too close to the wall i push him out with the help of the distance to the wall and the walls normal. but if i consider if the player is facing the wall or not gives jerky sliding at corners. If i include this code:if (planes[i].FacingWall(move_v)) (move_V is my direction vector) then the sliding is smooth around the corners BUT then the player is let out of the corners if the angle is less than 90 degrees. if i exclude it then everything works rock solid, but when sneaking around the corner at low speed gives you a too big correction, the player is thrown from the wall too fast. Here is my code, any suggestions? float min_distance_to_wall = 1.1f; for (int i=0; i < planes.size(); i++) { D3DXVECTOR3 vLength; D3DXVec3Subtract(&vLength,&planes[i].ClosestPoint(_camera.mPos),&_camera.mPos); vLength.y = 0; if (D3DXVec3Length(&vLength) < min_distance_to_wall) { float pushOut = min_distance_to_wall - D3DXVec3Length(&vLength); if (planes[i].FacingWall(move_v)) _camera.MoveCamera((planes[i].GetNormalVector() * pushOut)); } D3DXVec3Subtract(&vLength,&planes[i].ClosestPoint(_camera.mPos),&_camera.mPos); vLength.y = 0; }

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this