Hi,
I am working on implementing AABB collision and I can detect collision but say if you have a player AABB and the meshes AABB, when they collide, I set the player velocity to zero. However, since they are still colliding, the player can't get out anymore since velocity is zero. I'm doing this so the player does not go into the wall. I need to somehow push the player AABB out the colliding meshes AABB so the player collides but does not go through the wall. Essentially something like this:
I'm not entirely sure how you would do this and would appreciate any insight. This is my current collision handling function:
// position is the players position
// obj1 is the players AABB
bool AABBCollision(AABB obj1, const glm::vec3 position, const AABB& obj2)
{
obj1.min += position;
obj1.max += position;
return (
obj1.max.x >= obj2.min.x &&
obj1.min.x <= obj2.max.x &&
obj1.max.y >= obj2.min.y &&
obj1.min.y <= obj2.max.y &&
obj1.max.z >= obj2.min.z &&
obj1.min.z <= obj2.max.z
);
}