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 GraviterX · May 07, 2014 at 10:05 PM · animationjavascriptanimation.play

Animation Script

Hi all! I got this script off of Unity's scripting reference. I need to modify it to play my several animations.

 function Update () {
         if (Input.GetButtonDown("Fire1"))    
             animation.PlayQueued("shoot", QueueMode.PlayNow);
     }

Instead of "shoot" I want it to play my animations. So how do I list the names of all my animations in there? Thanks!

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 Fragmental · May 08, 2014 at 04:30 AM

One way to do this is with mecanim https://www.youtube.com/watch?v=Xx21y9eJq1U ,which might be your best bet, but a simple script like above does seem much easier.

Edit: I experimented some more and I got this to work. I had to restart Unity because it froze about a half dozen times in the process. Not sure why. I think it happened when I was saving the import settings.

When you import a file with your animations, you can find those animations in the inspector in the import settings when you select your imported asset in the projects window. You can then rename the clip or create new clips if you have multiple animations, in the same file. You can then select those clips and drag them where you need them from the project window after you expand your imported asset. Or sometimes you can find them in a list of assets when you click the options next to a parameter that takes an animation.

This is true for mecanim and the method you mentioned above. I believe that mecanim is the new way and the way you mentioned is the old way.

In order to use the old way, you must first set the animation type to "legacy" in the "rig" tab of your import settings. Then you follow what I just describe regarding creating your clips. Then you add the "animation" component, which can be found in "miscellaneous", to your object in the hierarchy of your scene. Then you can add an animation to "animation" which is the default or idle animation. Under "animations", you set the "size" to the number of animations you want to use with that object. Uncheck "play automatically"(unless you need your idle animation to automatically play). You should then be able to add the name of the animation you added to "elements" as a string in your script.

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

21 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

Related Questions

How would I go about carrying out another object's animation IN C#! 1 Answer

Animations Not Working 2 Answers

Play either the first or second animation on an object without specifying its name 1 Answer

How would you reccommend adding the jumping animation to my script? 0 Answers

Texture Swap + Animated Offset/Tiling 1 Answer


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