Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We’re making changes to the Unity Runtime Fee pricing policy that we announced on September 12th. Access our latest thread for more information!
    Dismiss Notice
  3. Dismiss Notice

Flexbile animation system / messy Animator

Discussion in 'Animation' started by FuriousFury, Apr 13, 2017.

  1. FuriousFury


    Feb 22, 2016
    Hi folks,

    currently I am working on a 2D action RPG (top down). Ever since I started I tried to make everything as flexible as possible.

    When it comes to animations I never found a good solution to my problem.

    Since I want the player to be able to charge his attacks I split up the attack animations into several sub-animations: start, charge, release. Somewhere in release I want a projectile to be spawned. I really don't like AnimationEvents since they are easy to overlook and therefore error-prone (in my opinion).

    Now the problem is that the Animator gets huge (and messy) with like 5 attacks (with 3 sub-animations each), doding, picking up items, dying, being dead, getting hurt, etc. pp. Mostly many Animations are attached to nearly each other animation (e.g. changing state from charging an attack into doding). I also have one Animator for each character. Other characters override this Animator with their own animations.

    Currently I have a StateMachineBehaviour on each AnimationState in Mechanim for the animations that calls a MonoBehavior about it's current state (e.g.: State: ChargeAttack, TimeInState: x seconds). Then in a coroutine I check the current state and e.g. spawn a projectile at a certain time (or start making the player invincible for doding).

    In short: how whould you approach many animations in the Animator and a flexible solution with Animations especially with split up animations? I want to be able to easily swap animations or variables for Animations (e.g. animation speed). And is there some best practices to keep complexity to the Animator to a minimum?

  2. dadude123


    Feb 26, 2014
    I'd just use one animation for every "logical" step.
    In your case you'd have one state for attack-start, one for attack-charge and finally one for attack-release.

    At runtime you'd just switch out the motion in that slot, that's all thats needed since the actual logic doesn't change:
    After start you always go to charge, and then you always go to release. So the only thing that really changes are the animations (motions) inside each state, right?

    That way your animator doesn't get messy.