Hi Everyone,
I'm having this weird issue with my code for projectile collisions in my 3D game.
My gun functions with casting a Ray and checking for collisions against Spheres around my objects , located in the appropriate Collision Tile, of my Uniform Grid Tile System.
Now everything works fin, but sometimes for a reason I can't figure out, my Ray Collides with spheres behind the character firing the gun. And so it screwes up everything, and since I have a sorting process right after collision detections that determines which collision happened first to determine which object takes the fire (because my projectile does not travel through objects) it makes it not work as it should.
Here is some code that shows you what going on.
DragonSC is a car object and here is the collision code that determines if the DragonSC's Collision Sphere, collides with the Ray being Casted.
x,y,z are the starting coordinates of my ray, starting at the Tip of the Fired Gun, xa, ya, za are the end coordinates of the ray (10000.0f further down the Line). Roty is the Angle the Firing character is facing and Rotx is the Angle at which the gun is firing, meaning at 90.0f the gun would be firing straight up in the air, parrallel to the Y axis.
Is there anything not right in my algorythm, I checked it 100 times using Sources on Stack Overflow and my Mathematics for 3D Game Programming & Computer Graphics Book by Eric Lengyel.
}
Thanks