Gamestudio Links
Zorro Links
Newest Posts
Zorro 2.70
by jcl. 09/29/25 09:24
optimize global parameters SOLVED
by dBc. 09/27/25 17:07
ZorroGPT
by TipmyPip. 09/27/25 10:05
assetHistory one candle shift
by jcl. 09/21/25 11:36
Plugins update
by Grant. 09/17/25 16:28
AUM Magazine
Latest Screens
Rocker`s Revenge
Stug 3 Stormartillery
Iljuschin 2
Galactic Strike X
Who's Online Now
3 registered members (TipmyPip, AndrewAMD, dBc), 18,430 guests, and 6 spiders.
Key: Admin, Global Mod, Mod
Newest Members
krishna, DrissB, James168, Ed_Love, xtns
19168 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
vec_dist is letting me down! #388541
12/04/11 06:24
12/04/11 06:24
Joined: Jun 2009
Posts: 26
D
dd231 Offline OP
Newbie
dd231  Offline OP
Newbie
D

Joined: Jun 2009
Posts: 26
Can someone tell me why the infantry unit won't stop when it reaches marker.x? When the distance is 1 or less it won't stop moving!! Probably so simple but here is the code

action infantry_pointer()
{

infantry = my;
while(!marker || !infantry){wait(1);}
var distance;
while(1)
{
distance = vec_dist(my,marker);
if(distance > 1) my.y-=5*time_step;

wait(1);
}
}

Re: vec_dist is letting me down! [Re: dd231] #388542
12/04/11 06:37
12/04/11 06:37
Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Superku Offline
Senior Expert
Superku  Offline
Senior Expert

Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
vec_dist only accepts VECTOR pointers, write
distance = vec_dist(my.x,marker.x);
instead.

Btw on low framerates distance probably will never be 1 or less, example:
- fps == 16, then time_step will be 1
- situation in one arbitrary frame: marker.x/z = my.x/z, marker.y = 10, my.y = 12.3
my.y -= 5;
- situation next frame: marker.y = 10, my.y = 7.3
...
my.y = 2.3, -3.3, ...

=> distance will never be smaller than 2.3


"Falls das Resultat nicht einfach nur dermassen gut aussieht, sollten Sie nochmal von vorn anfangen..." - Manual

Check out my new game: Pogostuck: Rage With Your Friends
Re: vec_dist is letting me down! [Re: dd231] #388544
12/04/11 07:47
12/04/11 07:47
Joined: Jun 2009
Posts: 26
D
dd231 Offline OP
Newbie
dd231  Offline OP
Newbie
D

Joined: Jun 2009
Posts: 26
nevermind! it had to do with the fact that it had to be at least 22 quants away.

Re: vec_dist is letting me down! [Re: dd231] #388547
12/04/11 08:14
12/04/11 08:14
Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Superku Offline
Senior Expert
Superku  Offline
Senior Expert

Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
What?
Don't write this:

distance = vec_dist(my,marker);


"Falls das Resultat nicht einfach nur dermassen gut aussieht, sollten Sie nochmal von vorn anfangen..." - Manual

Check out my new game: Pogostuck: Rage With Your Friends

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

Gamestudio download | 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