Too Good Collision Detection
9/1/2009
Nasty, Game Dev
(0)
One of the recent reviews for Nasty was critical of the hit detection, going so far as labeling one of the cons of the game "Dodgy Collision Detection".
I can tell you for a fact that in Nasty, when a collision is detected, it did in fact happen. The problem is not the game but rather the player's perception of what should be a hit and what should not.
There is a two step process for detecting collisions in Nasty, done for accuracy and performance reasons. First, a check on a bounding rectangle is done to see if one object is colliding with another. If a collision is found, step two of the process is done. If not, then the next set of objects are checked. Step two of this process examines the actual textures that will be drawn to screen and determines if any of the pixels from one object overlap the pixels in the other. If any of them do, then a collision has occurred.
The issue now becomes that even a slight, 1 pixel overlap is considered a collision. This means that even a tiny part of the player's body overlapping with an equally tiny part of the enemy's body causes a collision to occur and the player to be killed. While technically correct, such a small collision isn't always seen as fair to the player. And sometimes (worst of all), the margin is so small (and the frame rate so fast) that the player simply doesn't believe they were hit (I'm sure we've all played a game at some point where we've thrown our hands up in the air and yelled "No way that hit me!").
The solution to this problem is to make the initial bounding rectangle detection area smaller, thus allowing a slight overlap of objects before a collision is registered. Players enjoy this because they don't die as often and the close calls will end up being even closer and more exciting.
For Nasty specifically, I will be going through the game and examining the bounding rectangles for each player, enemy, and projectile, making sure that there is always some room for overlap, thus eliminating these perceived non-collisions and appeasing the almighty review Gods.
This article has been view 535 times.
|