1 registered members (AndrewAMD),
1,241
guests, and 6
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
patroll path
#425186
06/28/13 15:58
06/28/13 15:58
|
Joined: Feb 2010
Posts: 886
Random
OP
User
|
OP
User
Joined: Feb 2010
Posts: 886
|
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
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.
Last edited by Random; 06/28/13 15:59.
|
|
|
Re: patroll path
[Re: MasterQ32]
#425193
06/28/13 17:23
06/28/13 17:23
|
Joined: Feb 2010
Posts: 886
Random
OP
User
|
OP
User
Joined: Feb 2010
Posts: 886
|
The manual doesn`t explain how to get the entity patrol the path.
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?
|
|
|
Re: patroll path
[Re: Random]
#425196
06/28/13 17:51
06/28/13 17:51
|
Joined: Nov 2007
Posts: 2,568 Germany, BW, Stuttgart
MasterQ32
Expert
|
Expert
Joined: Nov 2007
Posts: 2,568
Germany, BW, Stuttgart
|
Manual: path_spline example
//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);
}
}
|
|
|
Re: patroll path
[Re: MasterQ32]
#425197
06/28/13 18:01
06/28/13 18:01
|
Joined: Feb 2010
Posts: 886
Random
OP
User
|
OP
User
Joined: Feb 2010
Posts: 886
|
Ok I got it working now.
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...
Last edited by Random; 06/28/13 18:18.
|
|
|
Re: patroll path
[Re: mk_1]
#425453
07/05/13 11:43
07/05/13 11:43
|
Joined: Feb 2010
Posts: 886
Random
OP
User
|
OP
User
Joined: Feb 2010
Posts: 886
|
nop
move_ent = ent_create(NULL,nullvector,NULL);
is not in a while loop. I just checked it again.
|
|
|
|