Search Unity

Is using Animators as founding for a State-driven architecture a good idea?

Discussion in 'Scripting' started by Elandir, Feb 7, 2020.

  1. Elandir

    Elandir

    Joined:
    Feb 9, 2014
    Posts:
    32
    Hi there.

    First let me put the question in context. Some time ago we learn about state-driven behaviours as defined in the Unity 5.x Cookbook (Matt Smith & Chico Queiroz) where they propose to divide behaviours in states with enter-exit-update methods; we immediately liked the idea and started to make extensive use of it in all our projects improving the implementation and making it better for each new one. At this point we use a Template State class which define Enter-Exit-Update-FixedUpdate methods and a Template Transition class to make links between states; we are very happy with how it works but it has some drawbacks we still are dealing with; the most significant are:


    n The implementation creates some significant overhead. Every ‘statable’ class needs to initialize all its states and transitions in the Start method which is a little messy and it’s also easy to make certain mistakes which later are hard to find(i.e. when initializing a transition, set the wrong state as target for that transition).


    n When the ‘statable’ entity has may states and transitions it became hard to understand how it changes through the time as we lack of any visual representation of it.


    The thing is that a few days ago we found this video
    and it seems to us a very nice approach for state-driven stuff as it would end with most of our current implementation issues. So my question would be this:

    Any of you is doing something like this? If so (or if you discarded it), is there any potential drawback?



    Thanks!!
     
  2. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    38,689
    Elandir likes this.
  3. Antony-Blackett

    Antony-Blackett

    Joined:
    Feb 15, 2011
    Posts:
    1,778
    In Major Mayhem 2 i used animation states to set variables for gameplay such as movementSpeed, canShoot, canJump, ect. It worked pretty well on the whole.
     
    Elandir likes this.