Search Unity

"Animating" quads using Unitys animation controller?

Discussion in 'Animation' started by mochiponzu, Mar 12, 2021.

  1. mochiponzu

    mochiponzu

    Joined:
    Mar 24, 2019
    Posts:
    10
    I'm using quads for displaying sprites because it has a couple of advantages over regular sprites when it comes to mixing with 3D. Practically, the sprite is the texture of the quad.
    Since Unity doesn't seem to have a built-in system to animate textures, I wrote a couple of scripts to dynamically change the material of the quad. That is, each frame of animation for the sprite is stored as a material, and the script switches through those materials at, say, 12 or 24 frames a second to create a sprite animation.

    Since the built-in animator system for 3D models and actual sprites is pretty solid with its states and transitions and their visual representation (you know, the flowchart thing), I was wondering if there's a way to use it within my script to determine the state, e.g. which animation should be played.

    The classes used by Unity are Animator and AnimatorController I believe, but I couldn't find any public variables in those that would let me access the states.

    Basically I'm looking for a way to use the robust flowchart system for arbitrary purposes WITHOUT having either a sprite or 3D animation attached. For example, it might also be useful if you had an enemy with an AI/script that had a lot of different states and transitions between them, to use the Animator as foundation and visual overview of which state leads to which, what the conditions for switching between them are.