So I’ve managed to get somewhere quite functional with AABB collision with the world (out of blocks) and the player/entity (one AABB), but I’m still having minor issues such as climbing walls or getting stuck in corners. I wonder if this is caused by a flawed implementation of AABBs or my collision code. This is what I have for collision so far:
public void move(float xd, float yd, float zd)
{
AABB tempAABB;
onGround = false;
ArrayList<AABB> possibleColliders = level.getSurroundingAABBs(entityAABB, 2);
for(AABB toTest : possibleColliders)
{
entityAABB.moveTo(x+xd, y+0.01F, z);
if(toTest.collides(entityAABB))
xd = 0;
entityAABB.moveTo(x+xd, y+0.01F, z+zd);
if(toTest.collides(entityAABB))
zd = 0;
tempAABB = entityAABB.growSides(-0.2F);
tempAABB.moveTo(x+xd, y+yd, z+zd);
if(toTest.collides(tempAABB))
{
if(yd < 0)
{
onGround = true;
y = (toTest.y1);
}
else
{
//Necessary?
}
yd = 0;
}
}
this.setPos(x+xd, y+yd, z+zd);
}
Am I approaching this very incorrectly? The player AABB is 1.8 blocks tall, and 0.8 blocks wide. Every block in the world is 1x1x1. If this is not enough code, I will gladly show what you need, I just want to avoid a giant wall of text if possible