Collision Detection
Collision Detection is the problem of detecting in-game when two or more objects intersect (or collide with) eachother. This is important because these collisions usually initialise triggers for (more) game behaviours. There are extensive calculations involved with collision detection in computer games, and because of this, many steps are taken to "optimize" how quickly these collisions can be calculated.
Per Pixel Collision Detection:
Per pixel collision detection checks every pixel in the game object for a "hit":Hitbox Testing:
For example, Street Fighter 2:Advantages of Hitbox (over Per Pixel):
- Optimization. In per pixel collision testing, the game engine will test every individual pixel in the object. Once there a multiple objects colliding at once, the number of calculations required to test all the collisions of all the individual pixels can grind even a small game to a halt.
- Not 100% accurate, but close enough, and the difference is often unnoticeable when done properly.
Disadvantages of Hitbox solution:
- Not 100% accurate (as previously said). Sometimes players can be "hit" when hiding behind walls (for example) if their hitbox is "viewable" past the wall's edge
- Other issues could arise with the "fit" of the hitbox, for example, players getting stuck in doorways when they look like they would fit through.