AABB swept collision response with voxel world

Started by
2 comments, last by user12345 9 years, 4 months ago

I followed this tutorial: link and I was able to make it work with 3d voxel world collisions.

But the problem I have is with collision response. I want to make player slide against the wall if he is running against it, but instead he gets stuck at each voxel edge.

That is happening because I am getting normals with AABB swept test from voxels that are a part of the wall. (Yes, I am doing broadphase check first).

WXUmj.png

In the image above is 2d representation of my problem. Voxels are black rectangles, blue one is player, red is swept check area and green lines are normals.

Possible solutions I thought of are: - Merging voxels into bigger collision boxes based on neighbours, but I think that would cause other problems when holes appear and player size increases. - Ignore collision normal if there is neighbour voxel along side normal. This is what I have currently in my code and works fine for sliding against walls while on ground, but fails when falling against them:http://ideone.com/xdsr2d (Btw, the code is dark and full of terrors)

Because there's many voxels in that are colliding and order of collisions (the order of voxels and normals that I receive after aabb swept test) is hardly predictable neither sollution seams to be good enough.

I would appreciate any help because I've been bashing my head around this problem for quite a while.

This originally was posted on http://gamedev.stackexchange.com/ but I thought it would also be good to post this somewhere else.


Advertisement

You need to find the closest collision first. Then do your collision response against that. Run the collision + resolution again using the time left and new position and velocity.

I've read somewhere about this, but I thought it would lead to the same problem when the player would be located exactly at the edge. I'll give it a try.

Rather than bring the object exactly to the edge, leave some space between them but also set the velocity opposite to normal to 0.

This topic is closed to new replies.

Advertisement