2D attack animation for Pokemon battle system

So as a way to learn Unity and its various tools, I’ve made a pokemon battle system. I know what it needs and should look like, so I figured it’s a great way to learn.

I have most of everything in place, but having some small issues with the animations for attacks. How would you approach this? I’m not looking for code, just what way you think would be best?

Currently I have a game object for each attack, that has an animator attached. The issue is, as I’m sure you would know, it can only really be in one spot. The animation runs on just one pokemon regardless of it being the attacking or defending pokemon.

What I would like to do, is have an animator over each pokemon and set what animation should play in that animator based on the attack and who the defender is. But it looks like that’s not really possible with code, unless I’m wrong. It seems like you can’t really set all the things the animator needs to know about, and it’s not as simple as just changing the animation, but the controller too.

The other two solutions I could think of is just make copies of each attack animation and place them over each pokemon. This seems sloppy. Which lead me to understand the way it’s set up is sloppy. If I were to develop this battle sim further it would end up having hundreds of attack animations in an idle state just sitting over each pokemon waiting to go off. That seems wrong.

The other solution would be to make the attack animations prefabs, and instaniatie them over the pokemon when its attack is called. This would give me the desired effect, but it seems excessive to make every animation a prefab. Maybe I’m wrong and this is the perfect solution and is exactly what prefabs are meant to be created and used for.

So how would you tackle the same desired effect? You would need to have an attack animation play over a target and that animation needs to be different based on the attack used. I really want to use the “just change the animation that can play in an animator” with code, but it looks like I can’t. If I’m wrong, please let me know.

Thanks in advance for just reading my question and giving it consideration. I know theres a lot of questions asked everyday, and I did my best to scour through them looking for a solution to my problem, but couldn’t find a question that was close enough to mine. I’m sure there’s one out there, so sorry if this is a repetitive question.

it’s been a while since i’ve done multiple animations on one sprite, but if i remember you will make a separate animation for each occurrence and it will call for a specific animation (i don’t want to say trigger because that is one of may instances that will call for an animation) based on the trigger/bool/toggle/button etc that you set for it.

this all takes place inside the animator controller. so lets say you have an attack animation, an injured animation, and a “static” animation for 2 pokemon that are fighting Charmander and Bulbasaur. i assume you have a code for receiving damage as well.

So inside Char’s controller you have 3 animations all coming off him for their respective moments and Bulb’s as well.

Char attacks which calls the attack animation, Bulb receives damage which call the injured animation, but both of those happen inside each respective prefabs controller, you won’t be able to call Bulb’s injured in Char’s attack. Char attacking is independent of Bulb, it’s that Bulb received damaged which called the injured animation not the Char attack that called it.


this is a pretty nice picture walkthrough, i can’t find the first one I had ever used to learn this. sorry