- Home /
How to change speed of animation in C#
I have an animation clip called "slideAnimClip" which runs perfectly when I play the game. However it's a prefab and I want many of these to be on the screen running at different speeds depending on circumstance.
Here is my script
 using UnityEngine;
 using System.Collections;
 
 public class slideBangScript : MonoBehaviour {
     
     public float animSpeed = 1f;
     public Animation anim;
 
     void Update () {
     Animation["slideAnimClip"].speed = animSpeed;
     }
 }
I think this should be correct, but I keep getting this error:
Assets/Scripts/slideBangScript.cs(12,9): error CS0119: Expression denotes a
type', where avariable',value' ormethod group' was expected
I'd be extremely grateful for any help.
Thanks.
Answer by kingcoyote · Apr 20, 2015 at 05:56 AM
Change
 Animation["slideAnimClip"].speed = animSpeed;
to
 anim["slideAnimClip"].speed = animSpeed;
Animation is a type, while anim is your member method that is an instance of that type.
Your answer
 
 
             Follow this Question
Related Questions
Animation Stop and Stay 1 Answer
How to get and change animation speed of animator? 2 Answers
Convert BPM to Animation.speed 0 Answers
 koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                