make the set target ignore previous point

I have a system to let a guard move and below is the script to select the waypoints…
for now it want’s to return to it’s previous waypoint, and I want to make him ignore it until after there are no unpassed waypoints anymore in range.

from bge import logic, events
max = 50
min = 5
close = cont.sensors['close']

def Main():
    wpl =[]
    for w in scene.objects:
        if 'waypoint' in w:
            if (own.getDistanceTo(w) < max) and (own.getDistanceTo(w) > min):
       = w
        for w in close.hitObjectList:

Why are you using such cryptic names? It makes the code very hard to read.

In general, you need a way to let remember passed waypoints, so you can skip them when selecting the next waypoint.

A) Preparation
First create an empty list of visited waypoints. You store it in a property e.g. “passedWaypoints”.

B) Discover the options
Now find all possible waypoints in detector range (I assume your “close” sensor is doing this).

C) Choose a waypoint
You select one of the waypoints by an algorithm of your choice ignoring any waypoint that is in the “passedWaypoints” list.
If you can’t select a waypoint, you need to think what to do next :wink: (e.g. clear “passedWaypoints” and continue with C) ).

D) Reaching the waypoint
When the object reaches the previously selected waypoint you add it to the “passedWaypoints” list. Then you continue with C).

I hope it helps