Jump to content
  • Advertisement
Sign in to follow this  
Meshboy

Corner Slide-correction too fast.

This topic is 3550 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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.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.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.FacingWall(move_v)) _camera.MoveCamera((planes.GetNormalVector() * pushOut)); } D3DXVec3Subtract(&vLength,&planes.ClosestPoint(_camera.mPos),&_camera.mPos); vLength.y = 0; }

Share this post


Link to post
Share on other sites
Advertisement
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!