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
1
Question by Hikaros · Jun 20, 2014 at 02:19 AM · animationanimatormecanimspeedclips

Problem adding individual clip speed

I've been trying to figure this out for hours now and i can't get it right :C

I have the player object which has an animator which has the controller. In this object i have about 3 different animations and i want to change the speed of one of them.

i know i can do something like: animation["swing"].speed = speed; but that gives me an error saying that there is no animation attached to player object.

i have one reference to the animator: anim = GetComponent(); and if i do anim.speed = speed; that does increase the speed but to every single clip. So how can i change the animation speed of one single clip?

Thanks in advance!

Comment
Add comment · Show 4
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 HarshadK · Jun 20, 2014 at 10:22 AM 0
Share

You might wanna refer to this thread that provides a work around.

$$anonymous$$ecanim - Change animation speed of specific animation or layers

And also refer:

Dynamic $$anonymous$$ecanim animation speed/time

Sometimes a Search does the trick! :-P

avatar image meat5000 ♦ · Jun 20, 2014 at 10:28 AM 1
Share

animation["swing"].speed = speed

is a legacy call, for Animation component, not Animator, which is $$anonymous$$ecanim.

I believe you can modify the speed of the whole layer but not an individual animation. To do this you need to alter it within the state machine.

To do it per animation simply detect the animation being played and conditionally set the speed of the layer.

Alternatively, set up a new state in the Animator which is the same animation, but faster, perhaps with a Blend Tree for a variable range.

avatar image HarshadK · Jun 20, 2014 at 10:33 AM 0
Share

@meat5000 you just summed up the two links that I provided. O$$anonymous$$G! :-0

avatar image Hikaros · Jun 20, 2014 at 06:53 PM 0
Share

I did search and for like 2 hours :C but all that came up was the animation.speed all over the place haha. I found most of the stuff too complex so i went along with working around of "Set playback of the entire Animator using [Animator.speed][1]. Note that this overrides the speeds of all states in your controller. Probably not your best bet.". Changed the entire animator speed before playing the animation i wanted and setted it back to normal in an animation event at the end of the last frame. Not sure if that is an "okay" way to do it so i will look into detecting the animation being played and set up the layer's speed. Thank you guys :)

2 Replies

· Add your reply
  • Sort: 
avatar image
6
Best Answer

Answer by KarlKarl2000 · Feb 12, 2017 at 04:16 PM

Sorry to necro a thread. But in case others find this thread like me.

Meat's answer is good. But it also speeds up all the animations on that particular layer.

Unity came up with a solution (finally) after a couple years.

https://forum.unity3d.com/threads/mecanim-change-animation-speed-of-specific-animation-or-layers.160395/page-2

sharing is caring

https://twitter.com/IndieNendoroid

Comment
Add comment · Show 1 · 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 meat5000 ♦ · Feb 04, 2018 at 01:31 PM 0
Share

Good find. I havent so well kept up to date on Additions to the system. You can have the Accepted answer.

avatar image
1

Answer by meat5000 · Jun 20, 2014 at 07:19 PM

Yes, use

 if( animator.GetCurrentAnimatorStateInfo(Layer).IsName("yourAnimation"))
 {
       animator.speed = animSpeed;
 }

Where Layer is the animation layer as int and animSpeed is a float to determine animation speed, where 1 is normal.

This way you can set individual speeds for individual animations.

I've never tried it though, I just whipped it up today to answer the same question from about 5 different people :D

So, you saw it here first :P maybe :D

Comment
Add comment · Show 4 · 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 Hikaros · Jun 20, 2014 at 09:22 PM 0
Share

oooohh this did the trick! thank you!

avatar image meat5000 ♦ · Jun 20, 2014 at 09:28 PM 0
Share

$$anonymous$$ost Welcome

avatar image RuneShiStorm · Feb 04, 2018 at 04:36 AM 0
Share

Late reply... 4 years late... Im trying to figure out how to Slow down PARTS of the animation... I like to use "add event" inside my Animation so I have control over exactly when the time should slow down. but how do I give that command inside a "void" (<--using void so I can see the event inside the animation when I add a flag on the timeline)

avatar image meat5000 ♦ RuneShiStorm · Feb 22, 2018 at 05:29 PM 0
Share

$$anonymous$$y advice here is to construct and submit a nice full question and we'll have a look :)

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

mecanim animation runs at random speed on iOS 0 Answers

Use Humanoid Animations with aditional bones 2 Answers

[Unity 4.3] Skinned legacy animations do not work 1 Answer

Mecanim - changing animation clip speed, through script? 4 Answers

Stop Animation State in Animator from Speeding Up after Playing it a Second Time? 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