• 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 ArkarKyaw · Mar 06, 2014 at 08:53 AM · animationmecanim

How to change animation speed in blend tree by script?

I want to set "This" value in the screenshot by script.Is there any way?Pleasealt text

toask.png (26.2 kB)
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 Subhajit-Nath · Mar 06, 2014 at 11:19 AM 0
Share

Was asked there as well.

http://answers.unity3d.com/questions/612520/how-to-access-blend-tree-speed-in-mecanim-from-c.html

2 Replies

· Add your reply
  • Sort: 
avatar image
4

Answer by augivision · Apr 02, 2018 at 09:18 AM

This answer may be a little late, but I wanted to achieve the same thing and this is how I accomplished it.

alt text

In my Blend Tree, I added the same animation with a lower Animation Speed.
Notice how I have the Walk motion twice. One with the speed set to 1 and another with the speed set to 0.5


This allows me to slow the walking animation if the player is pressing lightly on the joystick and speeds the animation up if the player presses the joystick harder.


I added a float parameter called speedPercent. In my code, I change the speedPercent by using:

 public Animator animator;
 
 
 if(walkingSlow)
 {
 animator.SetFloat("speedPercent", 0.3f)
 }
 
 if(walkingFast)
 {
 animator.SetFloat("speedPercent", 0.6f);
 }
 
 if(running)
 {
 animator.SetFloat("speedPercent", 1f);
 }
 
 else{ animator.SetFloat("speedPercent", 0f); }


This code is just an example, it is not the actual code.


manageanimationspeed.png (198.4 kB)
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
avatar image
0

Answer by duartejuca · Mar 14 at 05:01 AM

The animator speed property do this, but the animator speed work with all animations,so you have to change the speed for all animations in animator controlling them, for example, if your player movement, need to change the animation speed to run clip and want the animation more faster, you must change the animator.speed to 2. After this when you need to back speed, change the speed back to 1 in idle animation or other animation.

 private Animator animator;
 animator.speed = value;
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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

23 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

Related Questions

how to do an action at a certain point of an animation in mecanim 1 Answer

Humanoid Erratic Twisting at end of clip regardless of where I set the end of the clip. How do I avoid this or fix the problem? 0 Answers

How to properly place a rifle weapon into the Character's hands and change pose? 0 Answers

Playing animation when the heirachy has been changed. 0 Answers

Mecanim distorts 3D model 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