• Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by AeonAnomaly · Mar 13, 2019 at 07:04 PM · 2d animation

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.

Comment
Add comment · Show 2
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image MasterChameleonGames · Mar 13, 2019 at 08:17 PM 1
Share

Can't you make a Pokemon prefab ins$$anonymous$$d of creating animations for every single one? Apologies if this wouldn't work, I don't really use the Animation system.

avatar image AeonAnomaly MasterChameleonGames · Mar 14, 2019 at 07:30 AM 0
Share

I think I need to provide some further clarification in my question. $$anonymous$$aking the Pokemon prefabs wouldn't really solve my issue. The issue is that each attack in the game will have a special effect animation. Like the little flame from Ember or the splash of water from Water Gun. Currently, each attack has a GameObject with an animator attached to control the attack animations. However, there is only one version of each attack, so when I create the animation, it's just going to appear in that one location. I'd have to make copies of each attack, or make the attacks prefabs. Honestly, I should do that because if I were to set up Power Points for each attack currently, they'd be shared between all Pokemon using that move, lol. But by making each Pokemon a prefab, and each attack a prefab assigned to that one Pokemon, would make it so that Attack and its PP would be tied to that Pokemon.

I'm leaning more towards the Prefab Animation idea, seeing how I should probably have the attack itself be a prefab anyways. That way, I can instantiate the prefab animation right on top of the active Pokemon being attacked with no issues.

However, I was curious just how others would approach this same system, as maybe I'm over thinking and missing out on a more simple solution.

And thank you for your comment. I still have a lot to learn, and appreciate you taking the time to help.

1 Reply

· Add your reply
  • Sort: 
avatar image
1

Answer by surfuay · Mar 13, 2019 at 08:18 PM

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.

https://www.studica.com/blog/unity-tutorial-animator-controllers

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

Comment
Add comment · Show 3 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image AeonAnomaly · Mar 14, 2019 at 07:25 AM 0
Share

Thanks for your answer. I checked out the tutorial you provided, and that's about where my knowledge of animation and the animator currently is. I think I need to clarify a bit how I'm setting up the attacks. I'm not talking about changing the animation of the Pokemon itself, but I'm talking about the effects for all the attacks. So the small flame that appears when you use Ember or a splash of water with Water Gun. These are animations for the attacks themselves.

If I'm following you though, you might be suggesting to set up the animators for each Pokemon to have all the animations from the different attacks in the Pokemon's animator? That seems like a lot of work. I mean, right now it wouldn't be so bad with only 10 attacks, but if I were to expand on this battle simulator to include all the attacks, that would be hundreds of attacks in both active Pokemon's animators.

If that's honestly how you think the best way to approach it would be, I honestly think making prefabs for the attack animations would be the better path. If that's not what you meant though, I would love to hear some clarification.

Thanks again for taking the time to answer and provide a source! I appreciate the effort.

avatar image surfuay · Mar 14, 2019 at 07:32 AM 1
Share

I think if you're talking about the attacks themselves, I would just do a prefab. so I have an app where the player has multiple power ups moves etc. depending on what type of action it is I either instantiate a prefab on a buttons click/mouse click/touch or I set the prefab itself as a child to the parent (like putting a shield on the player) and when it's being used it's set to active. those are the 2 ways that I like to have actions that are "outside" the player to be done. I would not create 8 million animations of attacks for a single prefab tho, especially if they'll be recycled like ember for char and growlith

avatar image PhilPatterson66 · Nov 20, 2021 at 11:13 AM 0
Share

its sound like you are talking about pokemon fusion It seems too interesting that you can add the 2 pokemons and get an exclusive one as a pokemon fusion as pokemon combiner .having also a battle option in which you can utilize the water, explosion, web, fires, and clouds of dust.

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

103 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Rotate an animated gameobject (2D) 1 Answer

Jump Delay Animation Solution 0 Answers

Unity 2D My animator won't transition between states? Any help would be extremely helpful 0 Answers

Setting frame/time of current animation 0 Answers

I have a 2d animation that doesn't work with my colision box 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges