Search Unity

Different enemies with different animations

Discussion in '2D' started by sagf143g1f1f, Jun 3, 2020.

  1. sagf143g1f1f

    sagf143g1f1f

    Joined:
    Jun 3, 2020
    Posts:
    2
    Hi, I'm building a space shooter similar to Galaga and Space Invaders but I'm having trouble setting up the animations for my enemies.

    What I want to achieve is spawning a group of enemies of different types and all of them using the same animation, and the same group can be cloned but it can use a different animation set
    Now lots of ideas came into my mind but I don't know what's best and mostly important which one is more scalable

    My solutions:

    First
    Creating a bunch of animation clips and providing each enemy with a Legacy Animation, then from my SpawnManager set the required animation or a random one to all the enemy spawned in group

    Second
    Creating a single controller and a bunch of animations, each enemy is equipped with the controller and the spawn manager simply sets the current state to the Animator which plays the right animation

    Third
    Doing every animation as a script and then adding one of the scripts to the enemy object

    Is there any other solution? Should I use one of the above?
     
  2. Antony-Blackett

    Antony-Blackett

    Joined:
    Feb 15, 2011
    Posts:
    1,778
    If all you enemies have the same animation states, blending settings and transitions then you could look into using animator override controllers for each.

    https://docs.unity3d.com/Manual/AnimatorOverrideController.html

    if enemies have different states and transitions then you’re probably better off with unique animator controllers.
     
  3. sagf143g1f1f

    sagf143g1f1f

    Joined:
    Jun 3, 2020
    Posts:
    2
    I didn't know about this, thanks I will surely check it out!