Help with if statement conditional problem, please.

I thought I had conditional loops figured out- and I even got them to work in my game- until I had two objects that were both moving toward each other (on the x,z plane only)- they do not react the way other objects do.

for example:

 if not range(len(NPCsArray))==0:
       for ii in range(len(NPCsArray)): #checks for NPC's blocking path
             if not NPCsArray[ii].obj.isEmpty():
                      poschk= zombieArray[i].obj.getPos() - NPCsArray[ii].obj.getPos()
                      if poschk.length()<=0.1:
                           pos=NPCsArray[ii].obj.getX()-0.09
                           zombieArray[i].obj.setX(pos)#updates zombie's position     
                      elif poschk.length()>0.1:
                           pos=zombieArray[i].obj.getX()+0.02*
                           globalClock.getDt()
                           zombieArray[i].obj.setX(pos)
              elif range(len(NPCsArray))==0:
                   pos=zombieArray[i].obj.getX()+0.02*globalClock.getDt()
                   zombieArray[i].obj.setX(pos)

Works properly if the zombie hits a stationary object in NPCsArray[]- but he does not stop if he hits a moving one. The NPC object has a check almost identical to this one but checking for PCsArray[] items. Oddly enough sometimes the NPC stops moving- but the zombie doesn’t.

Basically if two objects come to each other and getPos()=<0.1: I want both objects to freeze in their tracks. I have wrote, checked and rewrote this section a dozen times at least and fiddled around with it for three days before giving up and seeking help.

What am I missing?

Feeling very frustrated at myself
JB SKaggs

I really feel stupid-

I had added the NPC’s to the wrong list and was never being checked.

JB :blush: