I have an entity that I move using c_move and I want it to be removed when it hits with anything.

The entity is created in code using this.

Code:
wait(-5);
	while (1)
	{
		VECTOR tvec;
		
		ANGLE tang;
		vec_set(tang,camera.pan);
		tang.pan = camera.pan + random(20) - 10;
		
		vec_for_angle(tvec, tang);
		vec_normalize(tvec, 2000);
		tvec.z = 600;
		vec_add(tvec,camera.x);
		
		ent_create("vogel.mdl",tvec,vogel_action);
		wait(random(8)-8.5);
	}



Wath it does here is create a new entity each x seconds, relative to the player. This works fine.

This is the action.


Code:
function vogel_action()
{	
	my.emask |= ENABLE_SHOOT;
	my.event = enemigu_evento;
	my.bida = 1;
	
	VECTOR tvec;
	ANGLE tang;
	while (1)
	{
		vec_set(tvec,camera.x);
		vec_sub(tvec, my.x);
		vec_to_angle(tang,tvec);
		my.pan = tang.pan;
		my.tilt = tang.tilt;
		
		vec_normalize(tvec,time_step * 60);
		c_move(my, nullvector,tvec,IGNORE_PASSABLE);
		if (HIT_TARGET)
		{
			ent_remove(my);
		}		
		
		wait(1);	
	}
}




Here everything works fine until it collides with something.
It gives an E1513 error that I traced to "ent_remove(my);".
I read in the manual what the E1513 error is and tried alot of things, but I can't find the error.

I tried.
Check if (my != NULL)
Put a wait(1) before "ent_remove(my);"
Use "ptr_remove(my)"
Use me instead of my.
Putting the c_move statement inside the if clause.
And a couple more things I can't remember.

If I press cancel on the message box, the game continuous normally.

Last edited by aaronde; 02/13/11 06:34.