Gamestudio Links
Zorro Links
Newest Posts
Blobsculptor tools and objects download here
by NeoDumont. 03/28/24 03:01
Issue with Multi-Core WFO Training
by aliswee. 03/24/24 20:20
Why Zorro supports up to 72 cores?
by Edgar_Herrera. 03/23/24 21:41
Zorro Trader GPT
by TipmyPip. 03/06/24 09:27
VSCode instead of SED
by 3run. 03/01/24 19:06
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
5 registered members (TipmyPip, AndrewAMD, Quad, aliswee, degenerate_762), 970 guests, and 4 spiders.
Key: Admin, Global Mod, Mod
Newest Members
sakolin, rajesh7827, juergen_wue, NITRO_FOREVER, jack0roses
19043 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 2 of 2 1 2
Re: Getting 3D-Coordinates [Re: Yking] #445173
08/29/14 11:16
08/29/14 11:16
Joined: Jun 2007
Posts: 1,337
Hiporope and its pain
txesmi Offline
Serious User
txesmi  Offline
Serious User

Joined: Jun 2007
Posts: 1,337
Hiporope and its pain
Originally Posted By: Yking
Maybe because I am using 7.5 Extra Edition?

Sure

Originally Posted By: Yking
is also not working because there is no Entity or something called terrain (I am only speculating this, might be wrong).

You are right. The terrain entity of the example is created on the run some code lines earlier.

That function computes the mouse position over a plane. It is the absolute objetive of your character. You only need to substract the global entity position to get the relative movement vector.

Code:
var speed = 10;
VECTOR vecMove;
vec_diff ( vecMove, vecMouseGround, ent.x ); //Get the movement vector
vec_normalize ( vecMove, speed * time_step ); // x = v * t;
c_move ( me, NULL, vecMove, GLIDE );



The orientation is taken from the movement vector.
Code:
ANGLE angTemp;
vec_to_angle ( angTemp, vecMove );
my.pan += clamp ( ang ( angTemp.pan - my.pan ), time_step * -0.3, time_step * 0.3 );


Last edited by txesmi; 08/29/14 11:16.
Re: Getting 3D-Coordinates [Re: Yking] #445191
08/29/14 19:46
08/29/14 19:46
Joined: Aug 2014
Posts: 57
Y
Yking Offline OP
Junior Member
Yking  Offline OP
Junior Member
Y

Joined: Aug 2014
Posts: 57
Thank you txesmi!
You absolutely and fully solved my problems, and you deserve a gold medal for that laugh !
Of course I also want to thank AceX, Reconnoiter and Superku, - you all helped a lot laugh!

I am going to post the full working code here, in case anyone ever has a similar problem.

Quote:

//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 laugh.
Btw. all credit to this code goes to the mentioned people, but especially txesmi laugh .

Re: Getting 3D-Coordinates [Re: Yking] #445196
08/30/14 05:31
08/30/14 05:31
Joined: Jun 2007
Posts: 1,337
Hiporope and its pain
txesmi Offline
Serious User
txesmi  Offline
Serious User

Joined: Jun 2007
Posts: 1,337
Hiporope and its pain
Glad to help grin
It is enough for me

Last edited by txesmi; 08/30/14 08:09.
Page 2 of 2 1 2

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1