Besides the Animator component, the manual often mentioned “Animation” as a component that can be referenced in a script and that seems very useful. For example in this entry:
public class ExampleScript : MonoBehaviour
{
public Animation anim;
void Start()
{
// Rewind the walk animation
anim["Walk"].time = 0.0f;
}
}
So I put this public Animation anim into a script of mine and it creates a field for an animation. However it won’t accept any of the animations I’ve created. They’re all 2D sprite animations, if that makes any difference. I can’t put the animator into it either. anim = GetComponent(); does nothing… so how do I actually use the Animation class?
Even if I could put something in it in the inspector, ideally I’d want to of course change the animation I’m accessing at runtime. Of course I’m most interested in changing the animation that’s currently being played by the respective animator component on the gameobject.