It looks like you're new here. If you want to get involved, click one of these buttons!
I am currently working on a 3D FPS, and I'm making progress. The game includes houses, collisions, enemies, shooting, and even an intro. But there's a problem I want to fix before continuing: The player can shoot through walls. My code works like this: "If shoot button pressed then iterate over each guard and check if the player is aiming at one", but I don't know how to change it so the player cant shoot through a wall before hitting a guard. I've been trying to figure this problem out for a while now, but this is all I could think of:
Right now, my code uses math to find out if a guard is hit. Instead, I could take a screenshot of the screen but color code everything and then check the pixels in the middle of the screen to see if they match the right color code.
The problem is that I fear that that process might be too slow. I would really like some help from you guys! The code is located in the gist below. The shooting detection code is located at around line 262.
Thank-you so much in advance!