qu3e icon indicating copy to clipboard operation
qu3e copied to clipboard

Sliding boxes "catch" on edges in floor

Open njbradley opened this issue 3 years ago • 7 comments

Hello! First of all, thank you for this library, I've been using it in my own voxel game, and it has been worked great! However, I've been stuck on this problem and I'm not really sure how to approach it.

Basically, the problem is that because this is a voxel game, the floor is made up of a bunch of different boxes. When objects slide on top of the floor, sometimes they will catch on a seam between two boxes and stop suddenly. I think this is happening because the object sliding on top is slightly protruding into the floor, and this part collides with the sides of the boxes in the floor.

Do you have any ideas to solve this? I tried changing the collision detection to ignore collisions on the very edge of boxes, but it's been hard to do this without ignoring actual collisions. Any help is appreciated!

Thanks!

njbradley avatar Dec 11 '21 02:12 njbradley

how about you make the boxes slightly bigger? so they overlap?

RobQuistNL avatar Dec 11 '21 14:12 RobQuistNL

Hmm, I tried that and it didn't seem to make a difference. I think because the sliding object is still protruding into the floor, it collides with the sides of the boxes. I'm thinking I might just write some code to disable the "internal" faces. Thanks for the suggestion!

njbradley avatar Dec 12 '21 03:12 njbradley

Yeah this is a common problem. There are many ways to tackle the solution, but the one I'd suggest is to add sphere collisions and use a sphere when sliding over the ground. This way the rounded edges can not get caught on the seams between boxes. It wouldn't be very difficult to add, and I can help you if you'd like to make a pull request to add spheres.

RandyGaul avatar Dec 12 '21 04:12 RandyGaul

I see, that makes sense! I was able to get it working by ignoring collisions on the internal faces, but I might need to use spheres later on. I'd be happy to implement spheres anyway, it seems like that would be a useful addition, and not too hard.

njbradley avatar Dec 19 '21 04:12 njbradley

Ignoring internal edges isn't going to be a very practical solution here. Of course you can try, but I think sphere will be far easier to get working robustly.

RandyGaul avatar Dec 19 '21 04:12 RandyGaul

The only reason I'm not going with the spheres is that I'd like to keep all the objects cubes. I feel like a cube collider with rounded edges would be perfect, but that sounds pretty difficult to make. I agree, disabling internal faces is not the best solution, but I can't think of a better one that keeps the sliding objects as cubes.

njbradley avatar Dec 21 '21 00:12 njbradley

One thing you can do is use a compound collider of both a sphere and a cube, then toggle each behavior depending on the scenario. You only need sphere when things are sliding around.

RandyGaul avatar Dec 21 '21 01:12 RandyGaul