- Home /
How do i change speed of 2D animation
I tried useing: animation["AnimationName"].speed = 2;`
I get the error "MissingComponentException" because i don't have an animation attached to the object, because i only use the "animator" component
if i add the animation to the object i get "NullReferenceExeption"
Comment
Looks like you are mixing Legacy and $$anonymous$$ecanim.
Answer by itsa · May 27, 2014 at 10:10 PM
Use animation window to make the animation, by changing the sample you can increase and decrease speed.
animationwindow.png
(30.3 kB)
using UnityEngine;
using System.Collections;
public class NewBehaviourScript1 : $$anonymous$$onoBehaviour
{
private Animator anim;
void Start ()
{
anim = gameObject.GetComponent<Animator> ();
}
void Update ()
{
if(Input.Get$$anonymous$$ouseButton(0))
{
anim.speed = 2f;
}
else
{
anim.speed = 1f;
}
}
}
Ugh! How can I change that value in a new version of Unity? I'm using 2019.2.11f1 and I can't find any sample field :c
You can enable the sample rate from the three dots at the top right of the animation window
annotation-2020-02-25-112658.png
(8.1 kB)