Select last target - Tower defense.
I am pretty far into developing a tower defense game, but I have run into a problem that i am unable to solve. I recycle 5 actors to make the enemies, so I do have access to their positions on the screen. I then have the towers find the distance of all actors using magnitude, Then when an enemy reaches a certain distance(the towers range) it changes attribute: self.target to 1-5 depending on which enemy is in range. Then shoots at the the enemy = self.target, that way it only attacks one enemy at a time.
MY PROBLEM: the towers then attack the last tower to enter its range, which is usually the newer towers, but I want it to attack the enemy closest to the end of the path. Any Ideas? They would be greatly appreciated.
MY PROBLEM: the towers then attack the last tower to enter its range, which is usually the newer towers, but I want it to attack the enemy closest to the end of the path. Any Ideas? They would be greatly appreciated.
Comments
Sorry about the watermark, can't figure out how to get rid of the darn thing. Anyways, the tower just lets the other enemies right by and attacks the last enemy to enter its range.