Sure there is a z-component involved. I assume you don't use an ISOMETRIC camera, correct? Then proceed as follows:

Your line is g(f) = mouse_pos3d + f*mouse_dir3d. You are looking for a specific f so that the z-component of g(f) is 0:

0 = mouse_pos3d.z + f*mouse_dir3d.z;
<=>
f = -mouse_pos3d.z/mouse_dir3d.z; // mouse_dir3d.z is != 0 because you are looking down

var f;
VECTOR dir;
vec_set(dir,mouse_dir3d);
vec_scale(dir,10); // depending on the camera height it can be beneficial to scale the dir vector for increased accuracy (because of the limited accuracy of var)
f = -mouse_pos3d.z/dir.z;
vec_scale(dir,f);
vec_add(dir,mouse_pos3d);

dir is now your target on the ground plane. Rotate your player to dir.


"Falls das Resultat nicht einfach nur dermassen gut aussieht, sollten Sie nochmal von vorn anfangen..." - Manual

Check out my new game: Pogostuck: Rage With Your Friends