• Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by unitydev0008 · Jan 21, 2011 at 08:02 AM · aiprojectiletower-defensetargetting

Basic Tower Defense Tower AI

Hey guys im currently working on a TD game and was wondering what would be the best way to go about making the tower AI. I was thinking having a sphere collider that would get targets as they entered the collider and assign them in an array, then check to see if the tower has a target if not it will select the closest enemy in the array and fire until out of range then rinse repeat.

I am new to AI so if this isnt the best way please help me out, also i was wondering what would b an effective way of handling the projectiles to ensure that they hit the target without it actually adjusting its course.

Thanks in advanced!

Comment
Add comment · Show 1
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image azzogat · Jan 21, 2011 at 08:33 AM 1
Share

That's how I'd go about the ai. As for the projectiles, just make them fast enough so any course adjustment would be minor and thus wouldn't be noticeable.

2 Replies

· Add your reply
  • Sort: 
avatar image
1
Best Answer

Answer by pfranza · Jan 21, 2011 at 01:00 PM

That is essentially exactly how a simple AI would deal with the problem, then only addition that you may want to consider is that you may wish to prevent 'overkill' That is if an entity is already targeted by enough towers to kill it during the cycle, you will want to choose a new target. If you don't do this, then you can have the condition where all the towers target the enemy at the front of the line only, and don't maximize the fire power efficiently.

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image unitydev0008 · Jan 22, 2011 at 10:10 PM 0
Share

I see the problem with too many towers targeting a single enemy, but not sure how to tackle it. I was thinking of doing a check of all enemies in the array of targets and checking if they have a tower targetting them, if not target that enemy, then after each target in the array has been checked( if we still dont have a target) just select the one closest like normal...would this do the trick or would it pretty much do the same thing...thanks =D and if u kno a more effective way plz let me kno

avatar image
1

Answer by psychicparrot · Jun 10, 2011 at 06:34 PM

If you are still looking for a solution, we have two awesome Tower Defense games complete with source code on ActiveDen.net - http://activeden.net/category/unity-3d/game-starter-kits

Sorry for the spam, but figured this might help?

Cheers!

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Joshua · Jun 10, 2011 at 06:38 PM 0
Share

It's not spam if it's helpful ^.^

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



Follow this Question

Answers Answers and Comments

2 People are following this question.

avatar image avatar image

Related Questions

Enemy AI Not Working? 1 Answer

Scripting Grenade AI. Checking if Array Objects are close to eachother. 1 Answer

AI aim and shoot projectile at Player 1 Answer

AI Target Finding Optimization 0 Answers

Enemy (AI) Doesn't shoot weapon projectile, until after the player is gone. 0 Answers

  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges