Jump to content
  • Advertisement
Sign in to follow this  
MrKyleMann175

Wall collision resolution question

This topic is 1671 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

Hi :), okay so i have made this 3D game with c++ and ive got walls involved that are being detected correctly bounding boxes using max X,Y,Z and min X,Y,Z and my resolution is to set the player's position a very small way back from the direction they walked into the wall (if the walked towards the wall the game would set the postion backwards by something like 0.001), it works fine when i have the movement speed to half of what i want it to but when the speed is what i would like it to be the player passes straight through the wall although as it is passing through it's movement is temportarly slowed down as it goes through the bounding box, does anyone know how i can make this work?

 

Thanks :)

Share this post


Link to post
Share on other sites
Advertisement

Yep ive just fixed it... all i had to do is alter the amount the player's position changes when the wall collision is detected and it works perfectly now :)

Share this post


Link to post
Share on other sites

This is not such a good solution, though. With this method you can't adjust the speed of something. Of course, if you have no need to adjust the speed, like in a runner, this would be fine, but otherwise you would have to have all objects moving at a static speed, and you would have to set the right offset for every object. One way you could solve this is to have a ray cast between the current and last position and check if the ray collides with anything, and if it does, just set the position of the object to where the collision occured and resolve your collision from there.

Share this post


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

  • Advertisement
×

Important Information

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

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!