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 ashjack · Sep 18, 2013 at 04:26 PM · animationaimecanimnpcrain

How do I use Mecanim on an NPC?

I am making an NPC, and of course it needs walking animations. I have all the animations I need ready. I am using RAIN(Indie) for the AI, and when he follows me, his walking animation does not play. I have set it up with mecanim, and the speed for it to start is 1, and he is moving towards me at speed 5. Firstly, how do I fix this, and secondly, is there a tutorial on using mecanim with an NPC?

Comment
Add comment · Show 8
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 ZenithCode · Sep 18, 2013 at 06:50 PM 0
Share

Someone/somewhere is setting 'speed' at 5. If you manually set the speed to 1, would the NPC move?

avatar image ashjack · Sep 18, 2013 at 06:51 PM 0
Share

I mean the npc should start the walking animation if the speed is 1 or greater. I tried setting it to 1, and then 5 to see if it would do anything. No good.

It's the RAIN agent that is setting the speed (and acceleration) to 5. I told it too, as stated above.

avatar image ZenithCode · Sep 18, 2013 at 06:55 PM 0
Share

So the problem is on your NPC controller. Is it possible that you have a conflict in your transitions?

$$anonymous$$g. If (speed > 1) -> $$anonymous$$ove and If (speed > 1)-> Idle

avatar image ashjack · Sep 18, 2013 at 07:07 PM 0
Share

Nope, no conflict there. The transition back to idle checks to see if the speed is less than 0.1, and the transition to walking checks to see if the speed is more than 1.

avatar image ashjack · Sep 18, 2013 at 07:07 PM 0
Share

Hang on, do I need a script to make blend trees work?

Show more comments

2 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by tanoshimi · Sep 18, 2013 at 08:33 PM

Using Mecanim for an NPC is no different from using Mecanim for a player character... it's a FSM - you set parameter values through script, and it processes transitions between animation states accordingly.

While your game is running, load up the animator Window (Window -> Animator), and drag it to one side so you can see it at the same time as your game window. Then, in your hierarchy pane, select the NPC object that has the animator control attached to it. The animator window will then show the states for this character in real-time, and the parameters window at the bottom left will show the values the mecanim animator is receiving from your code. The little blue line shows you the animation state that is currently playing. You should be able to see quite clearly what animation state your NPC is in, and why whatever transition you were expecting to occur is not firing

alt text


mecanim.jpg (117.8 kB)
Comment
Add comment · Show 7 · 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 ashjack · Sep 19, 2013 at 06:14 PM 0
Share

How do you set the parameter values through a script?

avatar image tanoshimi · Sep 19, 2013 at 07:05 PM 0
Share

It took you 22 hours to comment on my answer, and now you're bumping it because someone didn't reply to your comment within 47 $$anonymous$$utes...? I find that pretty rude.

Yes, you set parameters through scripts, as is explained clearly, with an example, in the mecanim documentation. I suggest you read it: http://docs.unity3d.com/Documentation/$$anonymous$$anual/AnimationParameters.html

avatar image ashjack · Sep 19, 2013 at 07:16 PM 0
Share

Sorry, I didn't mean to be rude, I can only be on my computer for a limited amount of time due to homework, and I just got impatient.

Where do I put the script? Do I put it in the character I am trying to control?

avatar image tanoshimi · Sep 19, 2013 at 07:27 PM 0
Share

Yes, that particular script you put on the gameobject that has the Animator controller attached to it (because, in the Start() function, it references it using GetComponent();).

avatar image tanoshimi · Sep 19, 2013 at 07:28 PM 0
Share

You should also seriously watch http://video.unity3d.com/video/7362044/unity-40-mecanim-animation-tutorial and download the associated project file, which illustrates a complete mecanim system.

Show more comments
avatar image
0

Answer by lancer · Sep 20, 2013 at 06:23 PM

I got Mecanim running with RAIN in like 5 minutes. Personally I don't think you have done enough searches. If you look up the RAIN YouTube channel it has a tutorial for how to do this.

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 ashjack · Sep 20, 2013 at 09:32 PM 0
Share

I have worked out what to do now. Thanks to everyone who helped!

avatar image tanoshimi · Sep 22, 2013 at 02:48 PM 0
Share

Please mark the question as answered then!

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

17 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

Related Questions

Mecanim Npc control 0 Answers

AI Movement (Jets, Spacecraft), Animation and Mecanim 0 Answers

Help on RAIN AI Basic Animator? (Documentation missing) 3 Answers

More realistically interaction with soccer ball 0 Answers

How to add new animations to enemy NPCs through mecanim? 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