Gamestudio Links
Zorro Links
Newest Posts
loading historical data 1st time
by AndrewAMD. 04/14/23 12:54
Trade at bar open
by juanex. 04/13/23 19:43
Bug in Highpass2 filter
by rki. 04/13/23 09:54
Adding Limit Orders For IB
by scatters. 04/11/23 16:16
FisherN
by rki. 04/11/23 08:38
AUM Magazine
Latest Screens
SHADOW (2014)
DEAD TASTE
Tactics of World War I
Hecknex World
Who's Online Now
0 registered members (), 1,012 guests, and 8 spiders.
Key: Admin, Global Mod, Mod
Newest Members
rki, FranzIII, indonesiae, The_Judge, storrealba
18919 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
vec_dist? :( #289529
09/13/09 19:06
09/13/09 19:06
Joined: Dec 2008
Posts: 83
Buenos Aires, Argentina
F
Funeral Offline OP
Junior Member
Funeral  Offline OP
Junior Member
F

Joined: Dec 2008
Posts: 83
Buenos Aires, Argentina
i have a problem with vec_dist i have an entity has to be removed when i get close to it but it just dissapear is that as soon as the level is open.
code

action item()
{
if (vec_dist(player.x, me.x) > 10 )
{
ent_remove(me);
wait(1);
}
}

no matter what number, it could be 10 or 100 or even a negative number but is always the same what's wrong with it?

Re: vec_dist? :( [Re: Funeral] #289531
09/13/09 19:16
09/13/09 19:16
Joined: Feb 2009
Posts: 3,207
Germany, Magdeburg
Rei_Ayanami Offline
Expert
Rei_Ayanami  Offline
Expert

Joined: Feb 2009
Posts: 3,207
Germany, Magdeburg
you must set a "while(player == NULL) wait(1);" bevore your if because at the start all entities are at nullvector wink

hope this helps!

EDIT: you even have to put the if in a while(1) wink!

Last edited by Rei_Ayanami; 09/13/09 19:18.
Re: vec_dist? :( [Re: Rei_Ayanami] #289532
09/13/09 19:18
09/13/09 19:18
Joined: Jul 2008
Posts: 170
Germany, near Mainz
Nicotin Offline
Member
Nicotin  Offline
Member

Joined: Jul 2008
Posts: 170
Germany, near Mainz
Alo you should say

action item()
{
if (vec_dist(player.x, me.x) < 10 )
{
ent_remove(me);
wait(1);
}
}

instead.
You where checking if the other objekt is further then 10 quands away. And not closer then 10



Re: vec_dist? :( [Re: Rei_Ayanami] #289552
09/14/09 01:18
09/14/09 01:18
Joined: Dec 2008
Posts: 83
Buenos Aires, Argentina
F
Funeral Offline OP
Junior Member
Funeral  Offline OP
Junior Member
F

Joined: Dec 2008
Posts: 83
Buenos Aires, Argentina
no still the same, if a replace the > for an < nothing happens
no matter how close or far i get form the item even if a change the 10 for a 1 or 100 is the same. maybe there's another problem? maybe a pointer? dunno
i'd need some example step by step. ive took this example from the aum 80 but it doesnt work for me

Re: vec_dist? :( [Re: Funeral] #289558
09/14/09 03:20
09/14/09 03:20
Joined: Mar 2006
Posts: 1,993
Karlsruhe
PadMalcom Offline
Serious User
PadMalcom  Offline
Serious User

Joined: Mar 2006
Posts: 1,993
Karlsruhe
Your problem is, that you are checking just once if there are entities near you. A while loop will help:

action item() {
while(1) { //echecking each frame
if(vec_dist(player.x,my.x) < 10) { //The 10 might be too small!!
ent_remove(me);
}
wait(1);
}
}

Not it should work! wink

Re: vec_dist? :( [Re: PadMalcom] #289559
09/14/09 03:27
09/14/09 03:27
Joined: Apr 2009
Posts: 248
Philippines
seecah Offline
Member
seecah  Offline
Member

Joined: Apr 2009
Posts: 248
Philippines
I think Rei_Ayanami answers your question completely.. before you implement a loop please check first if the player exists..

Code:
action item() 
{
	while( player == NULL ) { wait(1); }
	while(1) 
	{ 
		if(vec_dist(player.x,my.x) < 10) //play with 10
		{ 
			ent_remove(me);
		}
		wait(1);
	}
}



That should fix your problem...



Can't is not an option™
Re: vec_dist? :( [Re: seecah] #289622
09/14/09 14:24
09/14/09 14:24
Joined: Feb 2009
Posts: 3,207
Germany, Magdeburg
Rei_Ayanami Offline
Expert
Rei_Ayanami  Offline
Expert

Joined: Feb 2009
Posts: 3,207
Germany, Magdeburg
Thanks^^

Re: vec_dist? :( [Re: Rei_Ayanami] #289707
09/15/09 01:21
09/15/09 01:21
Joined: Dec 2008
Posts: 83
Buenos Aires, Argentina
F
Funeral Offline OP
Junior Member
Funeral  Offline OP
Junior Member
F

Joined: Dec 2008
Posts: 83
Buenos Aires, Argentina
theres must be something missing in other part of the script because no matter of i get close or far the item just doesnt do anyhting

function main()
{
level_load("z.wmb");
}
action player_script()
{
while(1)
{
camera.x = my.x -150;
camera.y = my.y;
camera.z = my.z +35;
c_move(my, nullvector, vector(joy_force.y/0.5 , joy_force.x/-0.5 , -2), GLIDE);
wait(1);
}
}
action item()
{
while( player == NULL ) { wait(1); }
while(1)
{
if(vec_dist(player.x,me.x) < 50)
{
ent_remove(me);
}
wait(1);
}
}

Re: vec_dist? :( [Re: Funeral] #289714
09/15/09 02:25
09/15/09 02:25
Joined: Sep 2008
Posts: 68
T
Tai Offline
Junior Member
Tai  Offline
Junior Member
T

Joined: Sep 2008
Posts: 68
Player = my;

Add that to your player script.

Re: vec_dist? :( [Re: Tai] #289808
09/15/09 17:33
09/15/09 17:33
Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Superku Offline
Senior Expert
Superku  Offline
Senior Expert

Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
And you can only remove the item once, the "me" pointer becomes invalid. This means that your loop has to stop ->

action item()
{
while( player == NULL ) { wait(1); }
while(me) // <-------------------
{
if(vec_dist(player.x,me.x) < 50)
{
ent_remove(me);
}
wait(1);
}
}


"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