Game Development Stack Exchange is a question and answer site for professional and independent game developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a room with objects inside. Each object has it's own AABB.

Sample image of objects in room

I know how to check for collisions between the objects with an AABB-AABB intersection.

How do I calculate an appropriate collision response to make them frictionlessly slide against each other as they collide?

share|improve this question
Are you talking about objects sliding on top of other objects here? What do you mean by "'sliding' / response"? – XiaoChuan Yu Mar 21 '12 at 18:00
XiaoChuan Yu - i want my Player object when in collision with other to get a response from Collision between two AABBs - so that when player gets into collision with sphere when walking - he slides on the sphere AABB face it collided with – PeeS Mar 21 '12 at 18:23
up vote 6 down vote accepted

What you're looking to do is have the solid object (wall, obstacle, etc.) push back with a force equal to that which the player is exerting on it. In a simulated physical world, applying forces will not result in the behavior you want, so the velocity of the player has to be changed directly. This is what's known as an impulse.

The impulse you want to apply to the player's velocity vector is:

impulse = -(player.velocity * collision.normal) * collision.normal

Where collision.normal is the normal of the face of the AABB that the player is colliding with. This is simply projecting the player's velocity vector onto the face's normal, obtaining the velocity change that the AABB will enact on the player (it is negated because technically we would subtract this vector from the player's velocity, but conceptually it makes more sense to add it). Finally, add the impulse to the player's velocity:

player.velocity += impulse

And the result will be the component of the players velocity which was horizontal to the obstacle, so the player will 'slide' along the object. Note that this will work even if the player is sliding directly along the sphere, provided you calculate the collision normal correctly.

Hope this helps :)

share|improve this answer
ktodisco, great answer ! Thanks. – PeeS Mar 22 '12 at 8:43
I find it useful to think of this as the vector rejection (actual name) of the player's velocity on the normal - vector rejection takes the player's velocity, and subtracts the part that is parallel to the normal, leaving only the component perpendicular to the normal (sliding along the object). – immibis Dec 30 '14 at 1:48

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.