Thank you txesmi!
You absolutely and fully solved my problems, and you deserve a gold medal for that
!
Of course I also want to thank AceX, Reconnoiter and Superku, - you all helped a lot
!
I am going to post the full working code here, in case anyone ever has a similar problem.
//Code for 3D-RTS-LIKE-UNIT-MOVEMENT
//Keep in mind, I use the 7.5 Extra Edition
BOOL vec_mouseground ( VECTOR *vecGround, var groundHeight )
{
if ( mouse_dir3d.z == 0 )
return FALSE;
var height = groundHeight - camera->z;
if ( !height )
return FALSE;
if ( (height>>31) != (mouse_dir3d.z>>31) ) //( sign(height) != sign(mouse_dir3d.z) )
return FALSE;
vec_set ( vecGround, &mouse_dir3d );
vec_scale ( vecGround, height / mouse_dir3d.z );
vec_add ( vecGround, &camera->x );
return TRUE;
}
function move_unit()
{
my = UnitThatIWantToMove;
VECTOR vecMouseGround;
while (1)
{
if (vec_mouseground(vecMouseGround, 200)) //The number should be the same z-height that your entity has
{
draw_point3d ( vecMouseGround, vector(0,255,0), 100, 30 );
var speed = 10;
VECTOR vecMove;
vec_diff ( vecMove, vecMouseGround, my.x ); //Get the movement vector
vec_normalize ( vecMove, speed * time_step ); // x = v * t;
c_move ( my, nullvector, vecMove, GLIDE );
ANGLE angTemp;
vec_to_angle ( angTemp, vecMove );
my.pan += clamp ( ang ( angTemp.pan - my.pan ), time_step * -0.3, time_step * 0.3 );
}
wait(1);
}
}
My formatting does not look too nice, but in the SED it should become more clear
.
Btw. all credit to this code goes to the mentioned people, but especially txesmi
.