# AABB - AABB Collision response ( sliding )

This topic is 2495 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Here is the situation: I have a room with objects inside Each object has it's own AABB Here is what i do: I check for collision between objects by checking AABB-AABB intersections Here is what i need: How do i calculate the 'sliding' / response between those AABBs? Here is what i have for AABB:  CBoundingBox::~CBoundingBox() { } int CBoundingBox::classify(const CBoundingBox& rOther) { if( rOther.min.x >= min.x && rOther.max.x <= max.x && rOther.min.y >= min.y && rOther.max.y <= max.y && rOther.min.z >= min.z && rOther.max.z <= max.z ) { return INSIDE; } if( max.x < rOther.min.x || min.x > rOther.max.x ) return OUTSIDE; if( max.y < rOther.min.y || min.y > rOther.max.y ) return OUTSIDE; if( max.z < rOther.min.z || min.z > rOther.max.z ) return OUTSIDE; return INTERSECTS; } CVector3 CBoundingBox::closestPointOn(const CVector3& vPoint) { CVector3 xClosestPoint; xClosestPoint.x = (vPoint.x < min.x)? min.x : (vPoint.x > max.x)? max.x : vPoint.x; xClosestPoint.y = (vPoint.y < min.y)? min.y : (vPoint.y > max.y)? max.y : vPoint.y; xClosestPoint.z = (vPoint.z < min.z)? min.z : (vPoint.z > max.z)? max.z : vPoint.z; return xClosestPoint; } bool CBoundingBox::hasCollided(const CBoundingBox& rOther) const { if( min.x > rOther.max.x ) return false; if( max.x < rOther.min.x ) return false; if( min.y > rOther.max.y ) return false; if( max.y < rOther.min.y ) return false; if( min.z > rOther.max.z ) return false; if( max.z < rOther.min.z ) return false; return true; } bool CBoundingBox::hasCollided(const CVector3& vPosition) const { return vPosition.x <= max.x && vPosition.x >= min.x && vPosition.y <= max.y && vPosition.y >= min.y && vPosition.z <= max.z && vPosition.z >= min.z ; } CVector3 CBoundingBox::getCenter() const { return (min + max) * 0.5f; } float CBoundingBox::getRadius() const { return getSize() * 0.5f; } float CBoundingBox::getSize() const { return (max - min).magnitude(); }  Longer description: I am absolutely sure you guys know what is the requirement here, i want "Player" to slide on other object's AABB's when in collision. Can somebody please shed a bit of light on the calculations required ?

##### Share on other sites
you need to figure out which face's axis-normal they collided the least, then move them that amount apart along that axis-normal. This will cancel movement causing the collision, but continue the other axial movements, allowing you to slide against the AABB.

##### Share on other sites
Net Gnome,

Any chance for any code snippet ?

##### Share on other sites
my journal Conquering SAT for TileMaps has a code reference in there, for Separating Axis Theorem for tilemaps (2D), but here are some excellent resources that should supply you with a lot of food for thought:

http://www.codezealot.org/archives/55
http://www.realtimerendering.com/intersections.html
http://www.gamasutra.com/view/feature/3383/simple_intersection_tests_for_games.php

• ### What is your GameDev Story?

In 2019 we are celebrating 20 years of GameDev.net! Share your GameDev Story with us.

• 15
• 14
• 10
• 9
• 11
• ### Forum Statistics

• Total Topics
634096
• Total Posts
3015493
×