Select last target - Tower defense.

FloridaGamesFloridaGames Member Posts: 328
edited December 2011 in Working with GS (Mac)
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.

Comments

  • EthanZarovEthanZarov Member Posts: 156
    So does the actor shoot the newer or the older ones first?
  • FloridaGamesFloridaGames Member Posts: 328
    I'll make a video of what I have so far.
  • EthanZarovEthanZarov Member Posts: 156
    ok thx
  • FloridaGamesFloridaGames Member Posts: 328
    edited December 2011


    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.
  • EthanZarovEthanZarov Member Posts: 156
    What might work is to make a time attribute of some sort to program the shooter to attack an actor with the tag of monster that has been in the radius the longest. I am pretty ure there is a way to do it with that.
  • FloridaGamesFloridaGames Member Posts: 328
    edited December 2011
    You might be on to something, I'll play around with that and see if I can get it to work. Thanks!
  • EthanZarovEthanZarov Member Posts: 156
    edited December 2011
    thx! I have been thinking it through now more thoroughly, and I realized that people might not place the towers in the correct place for this to always work. e.g.: someone could place it so that the monster comes into the radius, and then out of it again. So then maybe you want a time going for how long it has been in the scene, and when it is in the radius, the one that has been going the longest in the scene will be shot first
Sign In or Register to comment.