First thing you need to do is find the coordinates of the object using the mouse. This involves sending a trace from the mouse's position on the screen to the 3d ground below. (note this also assumes a birds eye view camera and a mouse in the game [mouse_mode = 2])
Code:
var from;
var to;
function mouse_trace()
{
from.X = MOUSE_POS.X; //set from.x to mouse_pos.x
from.Y = MOUSE_POS.Y; //set from.y to mouse_pos.y
from.Z = 0; //set from.z to zero
vec_set(to,from); //copy from to to
vec_for_screen(from,camera); //convert from to 3d coords
to.Z = 3000; //set to.z to 3000
vec_for_screen(to,camera); //convert to to 3d coords
return(trace(from,To)); //return the distance between from and to
}
What this code does is fire a trace from the mouse to the 3d spot right below it, giving us the coordinates. Each time trace is used, a built in variable called "target" recieves the coordinates of the final destination of the trace, where the trace ends. Now target is a very nasty variable as it always changes every frame and every trace, so as soon as we get it, we need to set it in a new vector.
Code:
function set_target()
{
mouse_trace();
vec_set(plrTarg,target); //copy target to plrTarg
}
on_mouse_left = set_target;
Okay, now we need to get our entity to move to that target.
Code:
action move_object
{
while(1)
{
vec_set(my.turnDir,plrTarg);
vec_diff(my.turnDir,my.turnDir,my.x);
vec_to_angle(my.pan,my.turnDir); //turn to target
if((my.tilt < 0) || (my.tilt > 0)) { my.tilt = 0; }
if((my.roll < 0) || (my.roll > 0)) { my.roll = 0; }
if(vec_dist(plrTarg,my.x) >= 10)
{
my.skill22 = 10 * time; //10 q per tick
my.skill23 = 0;
my.skill24 = 0;
move_mode = ignore_passable + ignore_passents + glide;
ent_move(my.skill22,nullvector); //go to target
}
wait(1);
}
So what is happening here? The entity enters a loop. Then he updates his rotation to point to the target in the next three lines. The next two lines after reset tilt and roll to zero so the target doesn't rotate in those directions. Then, if the distance between the target and the object is greater or equal to ten, the object moves to the target.
This code is untested. It is a modified rocket code actually, but it should work for an object on the ground. It only moves straight though, no pathfinding. If you want pathfinding, you've come to the wrong guy. I don't have any tips on that.

Where would you put this in a script? Just put them in somewhere in order as they are right here. Move_object is an action that should be attached to an entity in wed or ent_created during runtime.
And I would like to thank whoever gave me the mouse_trace code. I've used it in every game since.
