Collision detection
Posted by Eugene / 23rd October 2009 in Cool stuff, IGFEB09 - Team A, Production Diaries

I was tasked with implementing bullet collisions between players today. Found an algorithm on GameDev.net which is quite similar to the one from GamaSutra.com that we used for the IG200 pool game except this one does not involve square root operations. Implemented a check each frame for bullets colliding with players and removing the player’s health if a collision was detected. The particle manager would also be called and sparks emitted when a player was hit. The check would only take place if there were active bullets in the level to save processing time.

The problem was that the bullet was not returning its position correctly, a break point was set up and the position of the bullet checked. The Z position was accurate however it was not returning the X position of the bullet. Aaron and I replaced the collision detection code with a simple check to see if the distance between bullet and player was less that their radii to make sure there wasn’t a problem with the algorithm. Collisions were still not detected which suggested that the problem lied elsewhere.