patroll path

Posted By: Random

patroll path - 06/28/13 15:58

I noticed that you can set paths (nodes) in wed.
I wondered how I can use them.
I thought about something like:

If the destination and an target cannot be traced
Code:
if(my.target == 0 && my.goal == 0)



then somehow patrol the nearest path I laid in WED.

Can anybody explain what the commends are?
I couldn`t find anything like "find_path" in the manual.

Thanks fururemore.
Posted By: Bone

Re: patroll path - 06/28/13 16:04

Take a look at path_scan in the manual
Posted By: MasterQ32

Re: patroll path - 06/28/13 16:08

what about path_next?
Posted By: Random

Re: patroll path - 06/28/13 17:23

The manual doesn`t explain how to get the entity patrol the path.

Code:
if(my.target == 0 && my.goal == 0)
	{
		result = path_next(my);//find nearest path
		// 
		var speed;
		path_spline(me,my.x,speed);//follow the path?
		speed += 3*time_step;
	}



Nothing happens with this code.
Aren`t there any examples somewhere?
Posted By: MasterQ32

Re: patroll path - 06/28/13 17:51

Manual: path_spline example
Code:
//call camera_path(""); to let the camera run along a path in the level
function camera_path(pathname)
{
// create a dummy path entity
	me = ent_create(NULL,nullvector,NULL);
	path_set(me,pathname);
	var dist = 0;
	var vLastPos[3];
	var vDir[3];
	while(1) 
	{
// place the camera on the path
		path_spline(me,camera.x,dist);
		dist += 5*time_step;
// let the camera look ahead	
		vec_diff(vDir,camera.x,vLastPos);
		vec_to_angle(camera.pan,vDir);
		vec_set(vLastPos,camera.x);
		wait(1);
	}
}

Posted By: Random

Re: patroll path - 06/28/13 18:01

Ok I got it working now.

Code:
move_ent = ent_create(NULL,nullvector,NULL);
...
				result = path_next(move_ent);
		if (result) 
		{
			ANGLE offset_angle;	
			VECTOR AI_vec, temp_dir, pos_node;
			//////////
			path_getnode(move_ent, 1, pos_node, NULL);
			//
			vec_set(AI_vec, vector(4,0,0));
			c_move(move_ent,AI_vec,nullvector,IGNORE_PASSABLE | GLIDE);
			//
			vec_diff(temp_dir, pos_node, move_ent.x);
			vec_to_angle(offset_angle, temp_dir);
			move_ent.pan += ang(offset_angle.pan - move_ent.pan) * 0.2 * time_step; 
			//
			my.x = move_ent.x;my.y = move_ent.y;
		}



Thanks!
But there is one big problem, it is slow as hell...
Posted By: mk_1

Re: patroll path - 07/05/13 10:30

Probably because you create a new entity each time you call that code
Posted By: Random

Re: patroll path - 07/05/13 11:43

nop
Code:
move_ent = ent_create(NULL,nullvector,NULL);


is not in a while loop. I just checked it again.
© 2024 lite-C Forums