Originally Posted By: PadMalcom
Hey dice, this idea can be realised much easier, you do not need to create an entity and let the player walk there! Just use MrGuests method to trace from your mouse position to the ground and when you hit your terrain/block you have the vector your player will have to walk to.

@MrGuest don't you need to do a vec_to_screen on the mouse position at the beginning? And you have to trace down to -5000 not to 5000 otherwise you'll trace up into the sky.
here's it working
Code:
//trace

#include <acknex.h>
#include <default.c>

var TRACE_METHOD = 1; //change to 0 for mouse_ent method

ENTITY* trace_getEntity(long flags){
	
	VECTOR vecFrom, vecTo;
	
	vec_set(vecFrom, vector(mouse_pos.x, mouse_pos.y, 0));
	vec_set(vecTo, vector(mouse_pos.x, mouse_pos.y, 5000));
	vec_for_screen(vecFrom, camera);
	vec_for_screen(vecTo, camera);
	
	var trace = c_trace(vecFrom, vecTo, flags);
	
	if(trace){
		return(hit.entity);
	}else{
		return(NULL);
	}
}

void main(){
	
	mouse_mode = 4;
	level_load(NULL);
	
	int x, y;
	
	for(x = -128; x <= 128; x+=16){
		for(y = -128; y <= 128; y+=16){
			
			ent_create(CUBE_MDL, vector(x, y, 0), NULL);
		}
	}
	
	vec_set(camera.x, vector(-200, -200, 200));
	vec_set(camera.pan, vector(45, -45, 0));
	def_camera = 1;
	def_move();
	
	while(1){
		
		if(TRACE_METHOD == 0){
			if(mouse_ent){
				watched = mouse_ent;
				set(mouse_ent, LIGHT);
			}
		
		}else{
			
			you = trace_getEntity(SCAN_TEXTURE | USE_POLYGON | USE_BOX);
			if(you){
				watched = you;
				set(your, LIGHT);
			}
		}
		wait(1);
	}
}

vec_to_screen would convert a XYZ position to screen co-ordinates which we already have, and although -5000 would seem to make sense (using the traditional method of c_trace) it would place it 5000 quants behind the camera as you're converting it laugh