vec_dist driving me insane!

Posted By: rtsgamer706

vec_dist driving me insane! - 12/30/11 15:02

I am a programmer working with the free version of A8
I am using the command:
Code:
action go_down()
{
	triangle = me;
	if (vec_dist(me.x, character.x) <= 559) //this is the line that's driving me insane!
	{
		wait(1);
		ent_remove(me);
	}
}



and I was playing around with the value in the vec_dist to try and find one to my liking
that's where my problem began.
If the value is anywhere between 0 and 559
nothing happens, the entity never removes itself, no matter where character is
if the value is over 559 (560+) the entity removes itself the second the code compiles.
what am I doing wrong?!
Please help!
Rtsgamer706
Posted By: MasterQ32

Re: vec_dist driving me insane! - 12/30/11 15:29

your action is only called once!
you have to add a loop to your action:
Code:
action go_down()
{
	triangle = me;
	while(me)
	{
		if (vec_dist(me.x, character.x) <= 559) //this is the line that's driving me insane!
		{
			ent_remove(me);
			return; //Exit this function
		}
		wait(1);
	}
}


Posted By: Roel

Re: vec_dist driving me insane! - 12/30/11 15:30

Removed, someone was faster tongue

Posted By: rtsgamer706

Re: vec_dist driving me insane! - 12/30/11 16:13

I feel so stupid that I didn't see that!
Thanks for pointing it out!
works now!
Posted By: EvilSOB

Re: vec_dist driving me insane! - 12/30/11 16:32

Another way to go. Not BETTER as such, just different.
Up to you which suits you needs better...
Code:
action go_down()
{
	triangle = me;
	while(vec_dist(me.x, character.x) <= 559)
	{
		//other stuff...
		wait(1);
	}
	ent_remove(me);
}



[EDIT] I second SuperKu's suggestion...


Posted By: Superku

Re: vec_dist driving me insane! - 12/30/11 17:06

Btw. you should add a second loop before your current loop that waits until the pointer "character" is valid:

while(!character) wait(1);
while(vec_dist...
© 2024 lite-C Forums