Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • 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 /
  • Help Room /
avatar image
0
Question by Firedan1176 · Dec 30, 2015 at 10:42 PM · ai

Enemy AI: Best way for decision handling?

I've done a lot with AI pathfinding, and I'm starting a new "tower defense" based game, where enemies have a designated target and try to get to that, and in the end, defeat that target (which is a "core").

I don't want to simply have enemies go straight to the core like morons, apply damage and hope not to die, I want to have enemies who will target the "core", but also be able to stop and shoot or attack players of the game, defending the "core". Now, what would be the best way to determine this "decision", to stop and shoot at players, or to go to the "core", or to change a different path, possibly throw grenades, what kind of process can I go through? Preferably, do you know of any links to articles where people have already discussed this? I'm not sure what to look up, but I have tried.

Thank you.

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 Tom01098 · Dec 31, 2015 at 08:22 AM 0
Share

Well, a way I would do it is every enemy has either an OverlapSphere or an OverlapCircle being run on it every .1 seconds or something. You can have your pathfinding enabled, then when it detects something within a certain radius, shoot at it, then continue pathfinding to the core.

1 Reply

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

Answer by jmonasterio · Dec 31, 2015 at 09:38 PM

You can get AI behavior that appears "complex" to the player by implementing a few "simple rules".

The idea is similar to how a flock of birds (or school of fish) appear to fly (or swim) in a very coordinated fashion. The birds aren't all talking to each other :) Instead each bird follows a few simple rules like: "Try to stay the same distance from other birds near me". And "Try to follow the bird in front of me". But to an observer, it looks like the flock is moving in unison.

Anyway, you might want to have a few different rules like:

  1. "If there is a strong unit near me, try to go avoid it".

  2. "If there is a weak unit near me, try to fight it".

  3. "If I am weak, try togo directly to goal as fast as possible".

  4. "If there are already other of my units attacking a unit, ignore the enemy".

  5. "If I see any unit near me, pause to fight it 50% of the time."

  6. Give up fighting if I lose more than 30% of my strength, and continue to goal.

  7. ... make up a few more rules of your own.

Each rule should be individually easy to program. That is a benefit of this approach.

Perhaps then, you might have some units that randomly pick from available behaviors. Or some units that only do #1 and #3. Etc.

To the player the behavior may look quite complex even though the rules are simple.

Tune rules as necessary.

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 Firedan1176 · Jan 02, 2016 at 12:21 AM 0
Share

These are some great ideas, thank you so much!

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.

Follow this Question

Answers Answers and Comments

45 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

How do I make AI objects not walk on top of each other? 5 Answers

top Down 2D flight game AI 0 Answers

Raycast from NPC to player problem 1 Answer

C# or Javascript for enemy AI 2 Answers

Making the AI move randomly around the player's last known location 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges