Tower Defense
JGary321
Member Posts: 1,246
I was interested in creating a Tower Defense game & was having a little trouble getting started. I've already created another game (castle defense) which I will be posting once I put on the finishing touches.
But anyways, I need a starting point for figuring out how to determine attack range of my tower & that when an enemy passes that range it will "lock on" & shoot at it. And then when it goes out of range it will acquire new target.
Second thing is how to handle the AI. I can easily create it so they follow a path & you cannot build on that path, but I was thinking about possibly creating it so they actually can be placed anywhere (ala Fieldrunners) is this currently possible? If so where can I start with it.
I am not asking for a complete how-to of course, just a starting point. In the week that I've been using the tool, I recognize the power of it, & I feel I can do most things pretty well in it, but i realize I'm not a pro yet. So if anyone can give me a bit of guidance that would be awesome. Thanks for the support.
But anyways, I need a starting point for figuring out how to determine attack range of my tower & that when an enemy passes that range it will "lock on" & shoot at it. And then when it goes out of range it will acquire new target.
Second thing is how to handle the AI. I can easily create it so they follow a path & you cannot build on that path, but I was thinking about possibly creating it so they actually can be placed anywhere (ala Fieldrunners) is this currently possible? If so where can I start with it.
I am not asking for a complete how-to of course, just a starting point. In the week that I've been using the tool, I recognize the power of it, & I feel I can do most things pretty well in it, but i realize I'm not a pro yet. So if anyone can give me a bit of guidance that would be awesome. Thanks for the support.
Comments
You need an area around the turret to 'sense' if an enemy is there and start shooting at the enemy.
One way I imagine you could do this would be:
*Make an invisible actor that's a circle, and place it in the same position as your turret.
*The size of this invisible actor is essentially the turret's range.
*If an enemy collides with invisible actor make the turret shoot at actor.
This would actually possibly help with your second point about AI. Essentially, you could place these 'invisible area' actors anywhere and as long as an enemy collides with it it should work...
It's a similar method to that used in the 2D Metal Gear Solid games where enemy troops would have an invisible 'vision' cone in front of them. If you 'collided' with the vision cone, the enemy saw you!
Please bear in mind that I'm at work so I can't go into greater detail, or indeed check if this thinking would work or not!
Hope it helps somewhat!
QS
Dr. Sam Beckett never returned home...
Twitter: https://twitter.com/Quantum_Sheep
Web: https://quantumsheep.itch.io
also, i think theres a "bug" with collisions, where it only actually collides if the actor touches the edges of the other actor.
for example, if an actor gets spawned inside another actor, and does not touch the edges of the colliding actor, it wont trigger the collide event.
im having some problems over here with explosions, (which are larger actors) with this collide issue.
EDIT** After thinking about it for a few minutes, a square actor can still work. Everything but my empty circle would of course be invisible. So as long as my circle takes up most of the square I would be ok. Most players wouldn't even notice the split second the tower is attacking before the mob was hit. I try this when I get home & be more than happy to show how I did it, if anyone is curious. Of course initial credit goes to quantumsheep.
That still won't help with my pathfinding, but I can just do it based off a certain line they walk, no biggie on that right now.
My last question is how to get my tower actor to rotate towards the enemy, so that he constantly faces it. I'll try playing with the constrain attribute when I get home & see if that helps. I think I have an idea on how to get the bullet to "heat-seak" now, once I get that up I'll let everyone know. Thanks guys for the support.