Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Flexbile animation system / messy Animator

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

  1. FuriousFury

    FuriousFury

    Joined:
    Feb 22, 2016
    Posts:
    5
    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?

    Thanks,
    Fury
     
  2. dadude123

    dadude123

    Joined:
    Feb 26, 2014
    Posts:
    789
    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.