Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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 /
avatar image
0
Question by cdrandin · Aug 19, 2013 at 04:41 AM · aipathfindingdesignstructure

How to structure the code for your AI enemy system?

Hello,

I have been trying to figure out how to approach in creating an entire AI system for my game from the pathfinding, to combat, to thinking when to 'this' over 'that', when to run/hide/take cover. Somewhere along the lines.

I am curious as to how one would structure all these lines of code. I have a naive and simple idea on how to get the desired AI instructions to work, but should all of this be separate scripts to control the enemy, like AI_Path, AI_Combat, AI_Brain, etc or have them all in a huge script, which I think is unwise and just gets messy.

Another concern is I have read that FSM are quite helpful in the creation of AI, sometimes constricting, but for simple purposes they are useful. Is this simply achieved with naive switch statements or is there a more efficient way in handling all of the actions I would want to happen for the AI to take action.

If anyone could point me in the right direction for AI structuring or organization, of just overall tips to include when developing a system for the AI to obey.

One other side question, is Unity's Navmesh "good" enough to use for complex pathfinding or is it worth building a pathfinding system from scratch, being the only way I would know how to do is using raycast to help move the character along. As for complex, that I am not sure of. For the most part the terrain will be wholesome, meaning no gaps.

Any info would be helpful.

Thanks in advance.

Comment
Add comment
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

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by CodeAssembler · Aug 19, 2013 at 05:07 AM

I have tried this one and I found it somehow easy to implement following their video instructions:

http://arongranberg.com/astar/download#

As for the rest I guess its really more of personal taste than anything else. Unity is build modular and every GameOject its supposed to know 'how to live' on the game world and how to react to its environment. That's the philosophy I try to stick with myself. I don't really care that much about how the code is gonna end up looking or organized. I just follow this concept of Unity and I usually (most of the time) I end up happy with the results.

I will say, what I tend to watch is if the script is way bit and has to has references to a lot of gameobjects at the scene 'probably' I'm not doing things the best way and get away from the code and think about things the 'Unity way' to see if I can find a better approach. Buts this is really all about personal point of views more than anything else I guess...

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 cdrandin · Aug 19, 2013 at 05:23 AM 0
Share

Ah yes I have heard of that plugin before, just was never really sure about it, but I will give it a try. I do try my own way, but sometimes it has its good and bad. With each approach comes a good advantage structurally and logic syncing together.

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

15 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

Related Questions

Why isn't a Ai Waypoint Spawning??? 0 Answers

Enemy Movement AI in top-down, 2D, tile & turn based game 1 Answer

How do I go about making a 2d platform enemy ai 1 Answer

Pathfinding AI with Aron Granberg, Prefabs with AI not Retaining Target Transform, Trying to change for AI to Follow GameObjects with Tag "Player" PLZ HELP 1 Answer

Have falling object exit from a collider after collision? 2 Answers


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