point to point object avoidance? (need help)

im making a tower deffence game, and so i wanted the enemies to attempts to get to the players base, but how could i make it so that the enemies avoid the gun, rather than running into the guns. thanks a bunch


if walkingTowardGun():
    turnLeftOrRight()

Alternatively, you can have the attacker walk backward, or do something else that would actually protect them (assuming that’s the behavior you’re looking for).

I don’t know, but it would seem like that would defeat the tower defense feel if the enemies didn’t move in a preset path. Anywho, Social’s right that you could do some simple code to turn the enemies away from the gun.