Search code examples
collision-detectiongame-physics

What's this collision-detection-method called?


So, you have an multicolor picture that you print on the screen, and you have black and white picture that you use to check pixel-perfect collision.


Solution

  • I've used this in a system I dubbed Collision Masking, but some people call it Point-Square or Point-Point collision.

    The basic idea is you have one image that is the displayed graphics, and another image, usually black and white, that is the collision mask. Then, you have a parser that checks the world for a position's color, if it's black, there is collision(assuming you were in a previously white pixel), if white, you are free to go there.

    Note that this method can be very slow. Would definitely recommend hashing your collection of collision pixels for quick processing. It was also highly recommended to store the applicable pixels, since you want 100% precision, into rectangular sections to speed up the checking process further. Additionally, I'd recommend implementing a zoning feature, checking only the pixels around or at the area you are interested in, into the collision check.

    The main issue with this type of perfect masking is that it's reasonably slow but if you follow my suggestions above you should be fine.

    You can also extend this thought process to 3D collision as well but you need to incorporate colors into your masks.