path_scan(ENTITY* ent, VECTOR* pos, ANGLE* dir, VECTOR* sector)

Findet alle Knoten der Pfade innerhalb des Scankegels und liefert den nächstgelegenen zurück.

Parameter:

ent Entity-Pointer.
pos Scan-Ursprung
dir Scan-Richtungswinkel
sector.x Horizontaler Scansektor, oder Breite des Scankegels in Grad.
sector.y Vertikaler Scansektor in Grad, oder 0 für einen kreisrunden Scankegel.
sector.z Reichweite des Scans in Qunats.

Rückgabe:

Die Nummer des nächstgelegenen gefundenen Knotens, oder 0, wenn kein Knoten gefunden wurde.

Geschwindigkeit:

langsam

Modifiziert:

ent wird mit dem Pfad, der zum nächstgelegenen Knoten gehört verknüpft.

Bemerkung:

Beispiel:

 // move along a path loop (for smoother movement use path_spline)
 action patrol_path()
 {
 // attach entity to nearest path
  result = path_scan(me,my.x,my.pan,vector(360,180,1000));
  if (result == 0) { return; } // no path found
 
 // find first waypoint
  var node = 1; // start at first node
  path_nodepos(my,node,my.skill20);
 
  while (1)
  {
    var angle[3];
 // find direction
    result = vec_to_angle(angle,vec_diff(temp,my.skill20,my.x));
 
 // near target? Find next waypoint of the path
    if (result < 25) {
      node = path_nextnode(my,node,1);
      path_nodepos(my,node,my._TARGET_X);
    }
 
 // turn and walk towards target
    my.pan = angle[0];
    c_move(me,vector(3*time_step,0,0),NULL,GLIDE); // walk ahead...
    wait(1);
  }
}    

Siehe auch:

path_set, path_next, path_nextnode, path_scannode, path_spline

► Aktuelle Version Online