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
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.