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 RPMonkey · Oct 23, 2014 at 05:37 AM · animation

Unity animations not working

hi, I have tried many times to get animations to play with my gun when i press certain buttons. I have imported my gun from blender, and have made the animations on unity using the animation window. I have tried 2 different types of animation script so far, and none have worked.

First Script:

  function Update()
 { if(Input.GetMouseButtonDown(0))
 { // Plays the fire1 animation - stops all other animations 
 animation.Play("Shoot", PlayMode.StopAll); } }
 
 Second Script:
 
 if(Input.GetKeyDown("Fire1") && !animation.IsPlaying("Shoot")) 
 { animation.Play("Shoot"); }

Also when i play game, the animation for walking starts automatically without any scripts. Is there a way to stop this? And why won't my animations work? Please help. Thanks

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 Helical · Oct 24, 2014 at 09:50 AM 0
Share

The modern animation techinques dont make sense to me. I usually just set animations of an imported Blender model to Legacy. and then just activate things manually from code.

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by Sarthak123 · Oct 23, 2014 at 10:43 AM

i think you have set animation of walking as default animation in your player object, you should set it as a animation, not a default animation...please re-check the inspector..

Second thing, make your script like this.

 function Update()
 {
 if(Input.GetKeyDown(KeyCode.Mouse0))
 {
 animation.Play("Shoot");
 }
 }

and check your inspector and make sure Shoot animation is present in you animation list or not.

Check in the console for the errors generated during run-time...

hope this helps..

Comment
Add comment · Show 3 · 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 RPMonkey · Oct 24, 2014 at 07:15 AM 0
Share

How do i add animations to the object? Once i drag one in, the next one i drag in gets over written. alt text

animation probelm.png (461.8 kB)
avatar image Sarthak123 · Oct 24, 2014 at 08:29 AM 0
Share

actually you are using animator component rather than the animation component, unity uses 2 types of animations, first the simple basic animations which are controlled by animation component and second mecanim or complex animations controlled by a avatar and a animator compnent(you are tending to use this), further details you can find at unity's website, tutorials>animations and docs, in other way first delete this animator component first than click in "Select" button situated just below the name and tag options in the inspector and then go to Rig and then in the animation type select legacy..

then delete the animations of this character and its avatar and now go to add component, miscelaaneous, and then select animation, the one with play button sign, now re-record your animations, and then these scripts will work

I always do this, it may loo hard but is extremely easy once you learn the concept, please check the unity's tutorial to get in depth with this process,

Hope it helps and please reply if you have any other problems,

avatar image Sarthak123 · Oct 25, 2014 at 10:22 AM 0
Share

please accept it as correct answer if you think it helped..:)

avatar image
0

Answer by RPMonkey · Oct 26, 2014 at 08:55 AM

What do you mean by re-cording my animations? Does it mean to make it all again? Its says my scripts are trying to access 'animation'. I've been able to set the gun to legacy, and add all my animations into the play button component.

Thanks for all the help and it is really appreciated!

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

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

Multiple Cars not working 1 Answer

what's wrong with this script? 2 Answers

Scripting help 2 Answers

My player won't jump? 1 Answer

Need help with some OnTrigger Scripting 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