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
1
Question by DugelStudios · Jan 18, 2016 at 05:55 PM · animationanimatoranimator controlleranimationsanimationclip

How to get reference to a specific Animation Clip in Animator.

For the past 2 hours I have been searching everywhere and I can't find any resources to help me. The documentation is confusing (Especially for Animation) and every information I find is for a previous version of Unity that had a different animation system. Anyway, I have a GameObject with a Animator component attached. The Animator Controller has 4 animation states that it uses. I have a script attached to my GameObject and I can'd find out how to do the following: 1) Get the length any specific clip 2) Change the speed of any specific clip.

animator.speed = (some number) does not work because it changed the speed of ALL the clips. I want to change the speed of specific clips during runtime. Is there a way I can search the animation clip by name and change the clip speed? Or is there a way I can make a public AnimationClip, drag and drop the clip, and then edit the speed of the clip? And I want to change all of this during runtime, I know I can click on the Animation Clip and change the speed that way. Also, as I listed earlier, I need to get the length of the animation clip. I assume if I can change the speed of an animation clip, I can get the length of the clip because I'd have the reference to it. Any Help?

Comment
Add comment · Show 2
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 Cherno · Jan 18, 2016 at 06:31 PM 4
Share
  1. Unity recently made exposed the individual clip speed. You can make a clip's speed dependent on a animation variable, so just create a float "speed", link it to the speed, and change the speed from your movement script, for example.

  2. There is no simple way to reference an animation state. You have to first get an array of all states, then loop through then, and if the one you are searching for is reached, return that one.

avatar image DugelStudios Cherno · Jan 18, 2016 at 07:08 PM 0
Share

Thanks! Got it to work.

0 Replies

· Add your reply
  • Sort: 

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

54 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

Related Questions

How to interrupt and replay an animation? 0 Answers

How to reset animator controller ? 4 Answers

How to play an Animation only once from my MachineState Animator? 2 Answers

Animator Controller 2D RPG Best Practices 0 Answers

Some parts of animation not playing 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