Wall collision resolution question

Started by
1 comment, last by Christian Thorvik 9 years, 11 months ago

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 :)

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 :)

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.

This topic is closed to new replies.

Advertisement