I 've setup a 3D isometric setup where I could fire bullets to mouse position. So far so good. But if I get the intersection point from mouse to ground area and then fire on 2m height it looks bad as I don’t intersect the mouse pointed place. I’m pretty sure with some math calculation I could find out the correct velocity of my bullet to intersect the mouse position. I couldn’t fire direct to this position as this fires into the ground, which isn’t what I need.
Let’s say you have a line between your mouse point and your camera (we’ll call it mouseToCam). From the camera’s perspective, this line (mouseToCam) is a point. This means that any object positioned on mouseToCam will be at the same screen-space coordinate as your mouse. So…
Step 1: Position your bullet some place on this line.
“Hmm… but where”, you might ask.
Well, suppose you then have an XZ-plane (a flat plane with its surface pointing up) at the same y-coordinate as your bullet. When does the aforementioned line (mouseToCam) intersect with this plane? This intersection point will be where you should place your bullet.
Step 2: Compute the intersection between the XZ-plane and mouseToCam
But this brings up another problem. If I fire a coordinate “to near” to my character the fire direction looks weird. Maybe I’ll check if the mouse coordinate is to near to the character and in this case just fire straigh forward to the face direction.