Gamestudio Links
Zorro Links
Newest Posts
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
3 registered members (AbrahamR, AndrewAMD, ozgur), 763 guests, and 7 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Hanky27, firatv, wandaluciaia, Mega_Rod, EternallyCurious
19051 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 | 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