Kill function does not work

Posted By: TheShooter

Kill function does not work - 08/24/11 18:59

Hi,
I have some spikes. When the ball collides with them, the ball shall get removed. But it falls through the spikes.

Here my action code:

Code:
var abstand;
ENTITY* ent_piekser;

function kill()
{
	
	while(1)
	{
		abstand = vec_dist(ent_piekser, ent_ball);
		if(abstand = 0)
		{
			ent_remove(ent_ball);
			return;
		}
		wait(1);
	}
}



action piekser()
{
	ent_piekser = me;
	kill();
}



piekser = spikes.

abstand = distance

I included it in the main, and set the action in WED to the model.

Whats the problem here?

regards,
TheShooter
Posted By: Walori

Re: Kill function does not work - 08/24/11 19:27

Code:
if(abstand = 0)
		{
			ent_remove(ent_ball);
			return;
		}



Should be:
Code:
if(abstand == 0)
		{
			ent_remove(ent_ball);
			return;
		}


Posted By: TheShooter

Re: Kill function does not work - 08/24/11 19:36

Ok, thank you. But it does not solve the problem. But i think the problem is not the code. I i disable the action, the ball falls throught the spikes anyway.

But thank you for the tipp.
Posted By: Farodin

Re: Kill function does not work - 08/24/11 19:48

is the distance exactly 0? i would use the kill-function in an collision-event. then you didnīt have to compute the distance.
Posted By: xxxxxxx

Re: Kill function does not work - 08/24/11 20:07

ent_piekser and ent_ball aren't vectors, use ent_ball.x!
BTW: Your script trys to remove the ball when it has the same position then the spikes(this will never happen).
xxxxxxx
Posted By: TheShooter

Re: Kill function does not work - 08/24/11 20:31

Maybe I should use a collide detector. Becouse I have some "pieksers" above. And with that I'm a little bit flexiblier.
BTW:


Posted By: WretchedSid

Re: Kill function does not work - 08/24/11 20:36

Code:
action piekser()
{
	while(!ent_ball);
		wait(1);

	while(vec_dist(ent_piekser, ent_ball) > 0.01)
		wait(1);
	
        ent_remove(ent_ball);
}


© 2024 lite-C Forums