16

**General / Re: Whats wrong with my collision detection?**

« **on:**March 25, 2023, 09:36:41 am »

Collision detection is pretty easy if you break it down into smaller actions - it's only really complicated when you start trying to calculate complex physics simulations.

The basics of a collision involve calculating what's called a 'collision manifold'. This is composed of two things: a normal vector indicating the direction of the collision, and a penetration value - ie how much the two objects overlap. With these, resolving the collision usually boils down to moving the colliding object back along the normal vector by the penetration amount.

For AABB - AABB collision and circle-circle collision, finding this manifold is also really easy. I wrote this blog post for SFML specifically, which explains how to do it. Once you have an understanding of these types of collision then it's much easier to extend the technique to other shapes, although in many cases I've found AABB and circle collision is enough

The basics of a collision involve calculating what's called a 'collision manifold'. This is composed of two things: a normal vector indicating the direction of the collision, and a penetration value - ie how much the two objects overlap. With these, resolving the collision usually boils down to moving the colliding object back along the normal vector by the penetration amount.

For AABB - AABB collision and circle-circle collision, finding this manifold is also really easy. I wrote this blog post for SFML specifically, which explains how to do it. Once you have an understanding of these types of collision then it's much easier to extend the technique to other shapes, although in many cases I've found AABB and circle collision is enough