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 /
avatar image
0
Question by aeladas · Apr 03, 2019 at 01:57 PM · ainavmeshagentanimator controllerpathfinding

Creating a AI controller

I'm trying to create a simple AI controller that uses waypoints and 5 animations: Idle, Walk, Shoot, Take Damage and Death. I want the AI to travel to a way point then stop for a certain time then begin travelling to the next way point. I'll add the rest of the script in the comments.alt text

fq1.png (69.5 kB)
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 Nocktion · Apr 03, 2019 at 02:20 PM 0
Share

Okay... But what's your problem? What issue do you want to solve?

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by aeladas · Apr 03, 2019 at 03:07 PM

I'm trying to create an AI that will navigate terrain but also have the ability to stop as to simulate having a break, as well as shoot at a player. I'm not sure how to structure it into the controller script... Sorry if that doesn't make sense @Nocktion

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

Answer by Nocktion · Apr 03, 2019 at 04:56 PM

Okay okay. First of all if you haven't got any kind of barriers between two way points then you shouldn't have to use na navmeshes. If this is the case then it's pretty simple just rotate your AI character in the direction of the waypoint and using the walk animation travel the character to the point. Then create a random value e. G. int break = Random.Range(5, 15);, start the idle animation and use a coroutine to wait 'break' seconds before starting movement animation again. Meanwhile in the update function get an overlap sphere with the range of sight of the AI and check if there are any enemies in the array if yes then stop the walk animation, set your enemy as a target, rotate the character towards the enemy and trigger the shoot animation. If there are multiple enemies in range then do the same except you will have to compare their distance first then use the closest one as target. And lastly if the health of you character hits zero, trigger the death animation. The case is almost the same with a navmesh except you will have to use the waypoints given by the navmeshaicontroller or whatever it is called (sorry I don't remember it's exact name). So that's it. If something is unclear or you need some code, then just comment under my answer. Happy coding!

Comment
Add comment · Show 2 · 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 aeladas · Apr 03, 2019 at 05:21 PM 0
Share

Thanks a lot! I'll let you know if the controller works.

avatar image aeladas · Apr 04, 2019 at 10:50 AM 0
Share

Okay so I've tried to get the character to patrol but it won't go towards a way point. It just stays within the idle state, however when it does reach the waypoint the rotation starts to glitch out. Do you have any code handy that I could use as a template? I'll add a screenshot of my code when I can. Thanks

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

172 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 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 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 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

Horde of NavMeshAgents - stops to recalculate path. 4 Answers

Find the closest point of an Invalid or Partial path 0 Answers

AI pathfinding waypoints 1 Answer

How to build a custom shape NavMesh Area 1 Answer

Navmesh agent stuck on partial path 0 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