Gamestudio Links
Zorro Links
Newest Posts
AlpacaZorroPlugin v1.3.0 Released
by kzhao. 05/22/24 13:41
Free Live Data for Zorro with Paper Trading?
by AbrahamR. 05/18/24 13:28
Change chart colours
by 7th_zorro. 05/11/24 09:25
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
1 registered members (BrainSailor), 862 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
LucasJoshua, Baklazhan, Hanky27, firatv, wandaluciaia
19054 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
how can i move my entity from vector Temp1 to Temp2 #299949
11/28/09 13:30
11/28/09 13:30
Joined: Mar 2009
Posts: 207
E
Erick_Castro Offline OP
Member
Erick_Castro  Offline OP
Member
E

Joined: Mar 2009
Posts: 207
i defined two vectors:

VECTOR temp1;
VECTOR temp2;
vec_set(temp1 , my.x);
temp2.x = temp1.x + 1000;
temp2.z = temp1.z + 1000;


As you see, vec temp2 is 1000 in x and z far from temp1

i need to move my entity usin c_move, from my origianl position temp1 to temp2 in a speed that i can define (may be quick or slow )

Thanks

Re: how can i move my entity from vector Temp1 to Temp2 [Re: Erick_Castro] #299953
11/28/09 13:47
11/28/09 13:47
Joined: Apr 2005
Posts: 274
austria
Ascalon Offline
Member
Ascalon  Offline
Member

Joined: Apr 2005
Posts: 274
austria
VECTOR my_pos;
VECTOR target_pos;
VECTOR temp;

vec_set(temp,target_pos.x);
vec_sub(temp,my.x);
vec_to_angle(my.pan,temp);

// 10 is actuel speed, chance if you want go faster
c_move(my,vector(10,0,0),nullvector,IGNORE_PASSABLE | GLIDE);


my webside : www.ascalon.jimdo.de
Re: how can i move my entity from vector Temp1 to Temp2 [Re: Ascalon] #299957
11/28/09 14:13
11/28/09 14:13
Joined: Mar 2009
Posts: 207
E
Erick_Castro Offline OP
Member
Erick_Castro  Offline OP
Member
E

Joined: Mar 2009
Posts: 207
Ascalo, thank you. But i think it doesnt work
I will test it

Last edited by Erick_Castro; 11/28/09 14:31.
Re: how can i move my entity from vector Temp1 to Temp2 [Re: Erick_Castro] #299965
11/28/09 15:17
11/28/09 15:17
Joined: Apr 2005
Posts: 274
austria
Ascalon Offline
Member
Ascalon  Offline
Member

Joined: Apr 2005
Posts: 274
austria
please tell me, if it doesn´t work


my webside : www.ascalon.jimdo.de
Re: how can i move my entity from vector Temp1 to Temp2 [Re: Ascalon] #299971
11/28/09 15:41
11/28/09 15:41
Joined: Mar 2009
Posts: 207
E
Erick_Castro Offline OP
Member
Erick_Castro  Offline OP
Member
E

Joined: Mar 2009
Posts: 207
This is the code, Ascalon.

VECTOR my_pos;
VECTOR target_pos;
VECTOR temp;

target_pos.x = -1012;
target_pos.y = 413;
target_pos.z = 594;
vec_set(temp,target_pos.x);
vec_sub(temp,my.x);
vec_to_angle(my.pan,temp);

while(1)
{
if ( my.status == 1)
{
c_move (my, vector(10, 0, 0), NULL, GLIDE);
run_percentage += 6 * time_step;
wait(1);
}
wait(1);
}

As yo see, i defined target_pos as a vector -1012,413,594 coordinates.
The entity go good to that vector but then continues flying on the space
i need a code that when get the specified coordinates it stop the entity there.

The code works good, the only thing that i need is to stop the fly of the entity when it reach the position of target_pos

Thanks

Last edited by Erick_Castro; 11/28/09 15:44.
Re: how can i move my entity from vector Temp1 to Temp2 [Re: Erick_Castro] #299973
11/28/09 16:30
11/28/09 16:30
Joined: Mar 2009
Posts: 88
Walori Offline
Junior Member
Walori  Offline
Junior Member

Joined: Mar 2009
Posts: 88
You could try adding vec_dist to the code:

Original:
Code:
while(1)
{
if ( my.status == 1)
{
c_move (my, vector(10, 0, 0), NULL, GLIDE);
run_percentage += 6 * time_step;
wait(1);
}
wait(1);
}



To:
Code:
while(1)
{
if ( my.status == 1 && vec_dist(my.x,target_pos.x)>= 10)//Where 10 is the distance you want instructions to be executed
{
c_move (my, vector(10, 0, 0), NULL, GLIDE);
run_percentage += 6 * time_step;
wait(1);
}
wait(1);
}



Now when entity is close than 10 quants of target_pos it'll stop the movement

Re: how can i move my entity from vector Temp1 to Temp2 [Re: Walori] #299981
11/28/09 17:47
11/28/09 17:47
Joined: Mar 2009
Posts: 207
E
Erick_Castro Offline OP
Member
Erick_Castro  Offline OP
Member
E

Joined: Mar 2009
Posts: 207
Walori , it works good!

Thank you, Walori and Ascalon.

My best regards, friends.


Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

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