Game Development Stack Exchange is a question and answer site for professional and independent game developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am working on a small simulator. There is a 3D character on the screen and it randomly plays an animation (I used animation.PlayQueued(...) command inside a for loop). Now I have added a slider ( GUI.VerticalSlider ) on screen. I want to change the speed of all playing animations of 3D character when change the value of slider.

I know to use animation["animationNane"].speed=xx; but my problem is I have to pass the parameter of animation name that I want to change the speed . but actually I don't want to change the speed of specific animation clip. I want to change the speed of whatever the animation running in my 3d character. How can I change the speed of whatever animation is playing?

share|improve this question

From the sounds of it, you want to change the speed of any animation playing. So, essentially, you want to change the speed of all playable animations. The Animation class inherits from IEnumerable, so you can iterate through all clips via a foreach loop.


foreach (AnimationState state in animation) {
    state.speed = 0.5F;

Unityscript (Pragma Strict):

for (var state : AnimationState in animation) {
    state.speed = 0.5;

The above will cause all the clips within the animation object to play at half speed. You can then change the speed back, or to whatever, whenever you need to.

Unity Script Reference - Animation

Unity Script Reference - Animation Scripting (Legacy)

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.