Posted By: Random
Tpathfinding plugin - 07/08/13 16:24
I found the "Tpathfinding plugin" and I eminently tryed to use it.
However, when commend the AI to follow the player it just stands there...
Here:
Now comes the wired part. When I replace "player" with "camera" the script works, but only if the camera is in a certain distance and hight. So you have to play around with the camera position in order to make the AI move...
Does anybody know what I missed???
Thanks future more.
However, when commend the AI to follow the player it just stands there...
Here:
Code:
//////////////////////////////////////////////////////////// #define AI_state skill1 #define AI_idle 0 #define AI_chase 1 #define AI_go_home 2 ////////// action AI() { me.group=2; my.eflags |= FAT | NARROW; ////////// vec_set(my.min_x,vector(-10,-10,-10)); vec_set(my.max_x,vector(10,10,10)); ////////// PathFinder* my_pathfinder=tpf_CreatePathFinder(me); ////////// random_seed(0); // var find_time=random(3); var find_now=find_time; ////////// var my_ani=0; ////////// VECTOR pos_node; ANGLE angle_node; ////////// var go_home_find=false; me.AI_state= AI_chase; ////////// random_seed(0); int random_cost=random(6); ////////// ////////// ENTITY* move_ent = ent_create (NULL, my.x, moveing_ent); ////////// while(1) { switch(my.AI_state) { case AI_idle: if(vec_dist(move_ent.x,player.x)>=dist_goal) { me.AI_state=AI_chase; } break; case AI_chase: //don't find path very often if(find_now>=find_time ) { tpf_Clear(my_pathfinder); tpf_FindPath(move_ent.x, player.x,my_pathfinder,2,10,0,0); } find_now-=time_step/16; if(find_now<0) { find_now=find_time; } if(tpf_IsPathValid(my_pathfinder)) { my.x = move_ent.x;my.y = move_ent.y; ////////// if(my.state == 0) { if(c_trace(move_ent.x,player.x,IGNORE_ME | IGNORE_PASSABLE)>0 && you == player) { vec_set(pos_node.x,player.x); vec_sub(pos_node.x,move_ent.x); vec_to_angle(angle_node, pos_node); move_ent.pan += ang(angle_node.pan - move_ent.pan) * 0.5 * time_step; c_move(move_ent,vector(10*time_step,0,0),NULL,IGNORE_PASSABLE | GLIDE); } else { VECTOR* my_vec =tpf_NextPos(my_pathfinder,50); if(my_vec) { vec_set(pos_node.x,my_vec.x); vec_sub(pos_node.x,move_ent.x); vec_to_angle(angle_node, pos_node); move_ent.pan += ang(angle_node.pan - move_ent.pan) * 0.5 * time_step; c_move(move_ent,vector(10*time_step,0,0),NULL,IGNORE_PASSABLE | GLIDE); } } } } break; } ////////// wait(1); } }
Now comes the wired part. When I replace "player" with "camera" the script works, but only if the camera is in a certain distance and hight. So you have to play around with the camera position in order to make the AI move...
Does anybody know what I missed???
Thanks future more.