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 zviaz · May 04, 2015 at 06:50 PM · animationanimation controller

AI Patrol via Script

This might be a long post because my problem is (to me) quite complicated so I will try and make it detailed for anyone able to help because I have been trying for a solid four days and no results.

I have gone through all of the Unity tutorials (multiple times) and feel like I have a good handle on AI in general but they aren't very helpful when it comes to modifying their examples (or maybe it's just me)

I have done a lot of stuff with animating a character controlled by the player (in 3rd person) but now want to move in to more complicated AI behaviours.

So I have a basic floor (set to static) and a baked navigation mesh for the AI.

alt text

I also have 4 waypoints (represented by cubes) to indicate the AI patrol (waypoint 1 > waypoint 2 etc)

alt text

Then finally are the AI animations that will be used during patrol, chasing the player, attacking and death. (I can't attach any more pictures)

Normally (in my experience with player animations) I would setup an animation controller and attach it to the player in order to cycle through the animations with parameters.

For example, the transition from idle to walk might take a boolean of walking (true/false) and play the walking animation when the walking boolean is set to true.

Is this the preferable way to handle AI animations? Attatch an animation controller to the AI and a boolean like isIdle... then inside an attached script create an isIdle() method which is set to "true" on Awake()....

or do I attach all of the animations using the "animation" component and then cycle through animations via script (without the use of an animation controller)? so instead of isIdle() it would be something like

 void Awake() {
 animation.Play("Idle_01");
 }

The reason I ask this is because I tried setting up an animation controller where the default state is "Idle" yet the animation does not play. However, when attaching the idle animation as an animation component and selecting play on awake... the animation works fine. This leads me to believe I need a different approach to AI navigation/animation than I do with player animation.

The problem appears to be the fact that the AI rig is marked as "legacy" whereas previous models I worked with were "humanoid". Not sure how to resolve that issue though.

waypoints.png (204.5 kB)
navmesh.png (233.6 kB)
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
Best Answer

Answer by zviaz · May 04, 2015 at 07:29 PM

Found a solution (just incase anyone else has the same problem)

Both the AI model and the animations were set to legacy. I had to convert the model and animations to "humanoid" thus generating a new mask for the AI. This mask is then attatched to the AI via the animator controller and works.

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

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

19 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

Related Questions

Can I make animations snap to a frame? 1 Answer

Unity animator state finished, motion not 1 Answer

How to make 2D Sprite Animation frames spread over the duration of the motion time 0 Answers

Why have some of my prefabs and animations files gone blank?? 1 Answer

Change animations associated with an animator from C#? 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