I'm sure somebody post such a code before, nevertheless heres my version of it:
Code:
VECTOR mouse_click; //var mouse_click[3] for c-script
function mouseTo3D() {
while (1) {
if (mouse_left) {
vec_set (mouse_click, mouse_dir3d); //get direction vector from mouse to world
vec_normalize(mouse_click, 4000); //give it a large distance for tracing
vec_add (mouse_click, camera.x); //calculate from camera position
c_trace (camera.x, mouse_click, IGNORE_MODELS); //trace from camera to clicked position (= mouse position + 4000 in depth)
ent_create ("warlock.mdl", target.x, NULL); //accurate warlock placement!
}
wait(1)
}
}
