Tower Targeting

skippertech

  • Posts: 256
Hey Guys, I have been pulling my hair out on this for a few hours and I cant seem to figure out how to pull this off,

I am building a tower defense game, with simple enemys walking left to right. Basically what I am trying to do is get the tower to target an enemy. So it was suggested to me to once the enemy enters a region to target it. THAT part is simple. Where it gets difficult for me to figure out is what happens when a second enemy enters, and shortly after that first enemy dies or leaves the region, how can I get it to basically go down a list of choosing chronologically the enemys to target when they enter. (The tower can only shoot 1 enemy at a time)

The idea would be 3 enemys could enter nearly at the same time, but the tower would target the one that first entered, and when that enemy dies, the second one that entered and then the 3rd and so on. My goal is to make it never ending and smooth

ANY help or links to tutorials, example games, anything would be a huge help. Hopefully I make sense, Thanks guys.

SadiQ

  • Posts: 1795
Proud member of the League of Idiotic Stencylers! Doing things in Stencyl that probably shouldn't be done.

colburt187

  • *
  • Posts: 2416
Yeah Publyshers blog was a massive help to me,

Ive attached my TD behaviour, have a look at it, may not be exactly what your looking for. I have an event in here that also handles the towers rotation, so they smoothly rotate towards the target instead of just snapping to the target like if you used 'point self towards' (thanks to Photon)

Ive also added 2 options on how to add the target to the list, 1 is a simple when enters region block, which works well but when things get busy i have experienced this block missing enemies. The second is an always block which never misses and enemy but I'm not sure how it will work with multiple enemies in the region at once.

good luck.

PKrawczynski

  • Posts: 23
Yeah Publyshers blog was a massive help to me,

Ive attached my TD behaviour, have a look at it, may not be exactly what your looking for. I have an event in here that also handles the towers rotation, so they smoothly rotate towards the target instead of just snapping to the target like if you used 'point self towards' (thanks to Photon)

Ive also added 2 options on how to add the target to the list, 1 is a simple when enters region block, which works well but when things get busy i have experienced this block missing enemies. The second is an always block which never misses and enemy but I'm not sure how it will work with multiple enemies in the region at once.

good luck.

Its odd but your attached png file is of hammer, thats 48x48 pixels :)
Could you upload correct file maybe?

Photics

  • *
  • Posts: 718
Its odd but your attached png file is of hammer, thats 48x48 pixels :)
Could you upload correct file maybe?

That's how Stencyl works. Even though it looks like a picture of a hammer, Stencyl code is embedded inside the file. Importing the png into Stencyl with the "Import Resource" option will show it.
Michael Garofalohttp://photics.com – Author of The Interactive Stencyl Textbook 8)

PKrawczynski

  • Posts: 23
Its odd but your attached png file is of hammer, thats 48x48 pixels :)
Could you upload correct file maybe?

That's how Stencyl works. Even though it looks like a picture of a hammer, Stencyl code is embedded inside the file. Importing the png into Stencyl with the "Import Resource" option will show it.

Now thats some highly impressive sorcery I didnt expect :)
Forgive me, I'm still going through tutorials and manuals on site so I could have missed this :)
Very usefull feature.

colburt187

  • *
  • Posts: 2416
I thought he might want a hammer to smash his keyboard with if he couldn't get it to work ;)