Hello!
I have some problems with AABB - AABB collision. I successfully get the normal of the face I hit, but when I'm trying to resolve the collision (I'm trying to get the sliding working) sometimes I go through the wall, sometimes only by a bit.
Here is the code, where I try to resolve the collision.
if(BoundingBox.intersect(bb, Game.c2.bb))
{
Vector3f reaction = new Vector3f();
reaction.x = bb.norm.x * - (Vector3f.dot(bb.norm, movement));
reaction.y = bb.norm.y * - (Vector3f.dot(bb.norm, movement));
reaction.z = bb.norm.z * - (Vector3f.dot(bb.norm, movement));
Vector3f.add(movement, reaction, movement);
Vector3f.add(position, movement, position);
bb.setVecMin(new Vector3f(position.x - BBSIZE, 0f, position.z - BBSIZE));
bb.setVecMax(new Vector3f(position.x + BBSIZE, 1f, position.z + BBSIZE));
}
else
{
position.set(tempPos);
bb.setVecMin(new Vector3f(position.x - BBSIZE, 0f, position.z - BBSIZE));
bb.setVecMax(new Vector3f(position.x + BBSIZE, 1f, position.z + BBSIZE));
}