Search Unity

  1. Improved Prefab workflow (includes Nested Prefabs!), 2D isometric Tilemap and more! Get the 2018.3 Beta now.
    Dismiss Notice
  2. The Unity Pro & Visual Studio Professional Bundle gives you the tools you need to develop faster & collaborate more efficiently. Learn more.
    Dismiss Notice
  3. Let us know a bit about your interests, and if you'd like to become more directly involved. Take our survey!
    Dismiss Notice
  4. Improve your Unity skills with a certified instructor in a private, interactive classroom. Watch the overview now.
    Dismiss Notice
  5. Want to see the most recent patch releases? Take a peek at the patch release page.
    Dismiss Notice

Animation Override Controller

Discussion in 'Animation' started by symorian, Aug 1, 2018.

  1. symorian

    symorian

    Joined:
    Jun 7, 2017
    Posts:
    45
    Lately, I've strated to animate my entities with Animation Override Controller instead of assigning each a different Animation Controller.

    What I wonder is, I was able to change the animation speed per state in the Animation Controller.

    How can I achieve this with Override version? Because, the animation states are all same for some entities which is why I switched to animation override controller, yet, I need some of them run their i.e. Idle animation slower than the rest.

    When I click on the controller of the entity, it only shows the "Animation Override Controller" that it is derived from in the Animator window. Not the per-entity one.

    Any help is appreciated.

    Thank you.
     
  2. symorian

    symorian

    Joined:
    Jun 7, 2017
    Posts:
    45
    Just an addition, is adjusting the "samples" amount in the animation window the only way to control the animation speed when using Animation Override Controller which globally controls the animation speeds for several entities?
     
  3. Mecanim-Dev

    Mecanim-Dev

    Unity Technologies

    Joined:
    Nov 26, 2012
    Posts:
    1,611
    Hi,

    you can still control the speed of each state with the orignal controller, if you need to override the speed because the overriding animation is different then you need to expose a controller parameter to do this.

    Create a float parameter on your controller and then select your animator state and check Parameter just below speed and chose the parameter you just created.
    stateparam.png
     
    symorian likes this.
  4. symorian

    symorian

    Joined:
    Jun 7, 2017
    Posts:
    45

    Hi,

    Thank you for this. Actually I've used multiplier parameters for different purposes before but I couldn't just figure it out how to apply it to different type of enemies who use thier own controllers and that belong to Enemy class which has an animation override controller attached to.

    I mean her is my setup,

    Enemy Class (That has Animation Override Controller on it)

    - RoboEnemy (has RoboEnemy overrideController)
    - AxeEnemy (has AxeEnemy overrideController)
    ... etc.

    Now, i.e. I want my roboEnemies to run their idle animations therefore, idle states, at half speed of AxeEnemies. How am I gonna tell my EnemyClass that the current enemy in question is a Robo one and then set the multiplier parameter accordingly via script? I think I'm going to need to add some additional vars and conditionals? Or am I overlooking something?

    Maybe this can be it? ->

    I'll add "animSpeed" parameter in Main Animator Controller and assign it as the multiplier.
    Then, I'll do some assignment in EnemyClass i.e.


    Code (CSharp):
    1.  
    2. [SerializeField]
    3. private float enemyAnimSpeed;
    4.  
    5. EntityAnimator.SetFloat("animSpeed", enemyAnimSpeed);
    6.  
    7.  
    where enemyAnimSpeed is a SerializeField float where I can vary it depending on the type of enemy or even for single instances of each type of enemies?

    Is this an ok solution?
     
    Mecanim-Dev likes this.
  5. Mecanim-Dev

    Mecanim-Dev

    Unity Technologies

    Joined:
    Nov 26, 2012
    Posts:
    1,611
    yeah that sounds good if you can achieve what you want and the solution does bring any new issue
     
    symorian likes this.