Can I reuse my Animation?

Hey guy! i wonder why and how, i have some Object that have same Animation(Idle and Walk), but there only one different is Sprite, Walk animation is 2 sprites. i want to reuse this Animation Walk for All Object have Walk, just change Sprite of them, like i create Animation using transform(position,scale,rotate), i can reuse . Can i do it? is it possible? and How? thank for read, sorry for my bad English :smiley:

I don’t think so it is possible because you must have to specify the sprite frames there in animation, if the frames are different you can’t reuse them.

A possiblity (which may not be applicable for every case) is that you can add events on your animation, using that events you can change the sprite in script, but it is a bit overhead, and probably not good from performance point of view.

You can’t reuse a sprite animation but with different sprites, that’s another animation. It’s like saying “I wan’t to reuse my scale animation, but with different scale values”.

If you have another object that uses other sprites you need another animation clip.

What you can do is reuse the animator controller using an Animator Override Controller, look here: Unity - Scripting API: AnimatorOverrideController

And a tutorial: Unity3D: Reusing animator controllers with AnimatorOverrideController — pek

It’s also used in this other tutorial for the enemies: 2D Roguelike - Unity Learn

Another option you have is to do the animation at runtime, so you can reuse the code and only need to use a different set of sprites, but that’s kind of too much work to avoid making a second animation clip with 2 sprites.

Just thought i would chime in here with the best answer for me, which is to select (using ctrl a or drag, shift, or controls clicking) then copy all of the elements from the dope sheet in the animation and paste them into a new one, you can just replace specifically the sprite parts.