   Mode 7(pseudo 3D) - Using a ray-plane collision method
  Hi,I'm making a Mode 7(pseudo 3D) light gun game similar to Duck hunt, but with multiple layers. What I need to know how to do is to shoot a ray from layer 0(the layer the player is shooting from) to say, layer 3(the layer the enemy is in). Since my game will be using a light gun, if they click at (100, 50) on the screen, I need to be able to shoot a ray from (0,0, 0) to (100, 50, layer #). The layer the enemy is in will directly correspond to the enemy's z-position for calculations. My question is, if I use a plane for the enemy's bounding box, how could I shoot a ray from the player's layer at position (0,0,0) to the enemies position (100, 50, 3), and how could I go about about checking to see if there was a collision? The way I figured was just to cast the ray, then check each layer from back to front (3 to 0), and check for a collision with a plane in each layer. Then, save whichever layer closest to the player that had a collision. Does anyone have any ideas better than this?Layer 3----(Enemy position (100, 50, 3) )-----------------------^Layer 2----------------|-------------------ray-|Layer 1----------------|  -----------------------|Layer 0----(Player position (0, 0, 0) )Here is some pseduo-code:bool CheckCollision(int * collisionID) // collisionID will hold the ID of the object collided with{  Cast ray from player position to position player shot at;    for(x = num_layers; x > 0, x--)  {    Iterate through each object's(in current layer) bounding plane and check for a collisionthe ray;    If there is a collision, set _collision = true and store the object's  ID into variable closest_ collision;   }   if(collision == false)   { collisionID = NULL; return false;   }   *collisionID = closest_collision;   return true;}Does that sound reasonable?   