make entity remove after reaching end path :)

Posted By: Realspawn

make entity remove after reaching end path :) - 08/29/15 22:39

this is what i use now :

Code:
action moveontrack_01()
{
	var walk_percentage;
	var walking_speed = 0.3;
	VECTOR last_pos[3];
	VECTOR direction[3];
	var distance = 0;
	var dist_to_node;

	var current_node = 1;
	
	set(my,SHADOW|PASSABLE);
	path_set(me, "path_000"); 
	while(1) 
	{
		ent_animate(my, "run", walk_percentage, ANM_CYCLE); // play the "walk" animation
		walk_percentage += 6 * time_step; // "3" controls the animation speed
		path_spline(me, my.x, distance);
		distance += walking_speed ;
		vec_diff(direction, my.x, last_pos);
		vec_to_angle(my.pan, direction);
		vec_set(last_pos, my.x);


		wait(1);

	}

now it keeps cycling :) how to remove it when it comes to the last point of the path ? :)

thx for your time and help :)


}

Posted By: JcI_the_second

Re: make entity remove after reaching end path :) - 08/29/15 23:18

You can put one entity on end of the path, and when your moving entity get close to this point then remove your moveontrack entity
if(vec_dist(my.x,flag_ent.x) < 50){ ent_remove(me);}
Posted By: Realspawn

Re: make entity remove after reaching end path :) - 08/29/15 23:22

I was thinking in that way like making it react on a model near the end point laugh

i will give it a shot thank you laugh
Posted By: Anonymous

Re: make entity remove after reaching end path :) - 08/29/15 23:39

Code:
action car(){

	track_select=random(2);; // GLOBlE NOTICE
	//if(track_select >2)
	//track_select = 1;
	if(integer( track_select) ==0)
	path_set(my,"path_000");
	if(integer( track_select) ==1)
	path_set(my,"path_001");
	
	/////////////////////////////////////////////////////////////////////
	
	my.NODE_NEXT=path_nextnode(my,1,1); // SET THE NODE
	while(1)
	{
         // PATH NODE DETECTION AND RANDOMIZATION AND FACING //////////////////////////////////
		
		
		if(vec_dist(my.x,vec_next_node.x) < my.max_x)    
		{
                  // HERE you have to adjust the code REALSPAWN
                  if(my.NEXT_NODE == 10) // replace 10 with the number for the last node, inside the cheese
                   ent_remove(me);
   
			//path_next(my); // will jump from current path to new path// Jump to new path
			my.NODE_NEXT=path_nextnode(my,my.NODE_NEXT,1); // Grab Next node on new path -- NOTE ALL PATHS MUST HAVE THE SAME NUM NODE IN SAME GEN LOCATION
			
		}
		
		path_getnode(my,my.NODE_NEXT,vec_next_node,NULL);  // Get next node actual vector location 
		
		
			vec_to_angle(my.pan,vec_diff(NULL,vec_next_node,my.x)); // face the new node
		

		///////////////////////////////////////////////////////////////////////////
		
		// SOFT AND HARD MOVEMENTs /////////////////////////////////////////////////////////////
		
		c_move(my,vector(my.skill3*time_step,0,0),nullvector,GLIDE | IGNORE_PASSABLE);
		
wait(1);
}
}



test and play with this. This does seem to work but the ent_remove will cause a crash.

Posted By: JcI_the_second

Re: make entity remove after reaching end path :) - 08/29/15 23:47

Originally Posted By: Malice
test and play with this. This does seem to work but the ent_remove will cause a crash.

not if we put 'return' after 'ent_remove' wink
Posted By: Anonymous

Re: make entity remove after reaching end path :) - 08/29/15 23:52

you are correct or move the ent_remove out the loop.
I was just telling spawn because he knows i uninstalled 3dgs and would not be testing this when he ask me to make the hacks
Posted By: Realspawn

Re: make entity remove after reaching end path :) - 08/30/15 01:54

I used a simple object that removes the rat laugh
no crashes anymore fixed it all. I will soon upload the demo.
© 2024 lite-C Forums