CREATE A SCRIPTABLE OBJECT CONFIGURATION ASSET "AnimationSO”


"AnimationSO scriptable object" is the main configuration asset of "EASY ANIMATOR CONTROLLER". Once the concept is understood, it is easy to adapt it to the AnimationClips you intend to use.

 

When we analyze a pack of animations of an artist, we see which words he uses to name them and this analysis must consider the three levels of information that we can encode.

 

We will explain step by step all the parameters to be configured in "AnimationSO scriptable object".

The necessary "AnimationSO scriptable object" is created following this process: (Path: Assets -> créate -> "AnimationsSO").

We show an overview with all the sections to be configured.

First, we analyze the basic information level to include all animations in a "MAIN_ANIMATION_CATEGORIES". By default, the following categories are created when creating a new "ANIMATIONSO scriptable object".

The first thing we want to emphasize is that the order matters since each "AnimationClip" can only belong to one main category and they are evaluated in order from top to bottom. Thus, an animation that includes the keywords "ATTACK" and "CROUCH" in its name will belong to the category "ATTACK" and not "CROUCH" because it is positioned first in the list. This order becomes a further configuration factor. For example, an attack in position "crouch" is an attack and "crouch" in this case is additional information level of type "Position State" category "CROUCHING".

Within each category several variables are initialized. In order:

Variable "Name": Defines the name of each main category of animation type. It does not matter if there is an "AnimationClip" that includes this main name, what matters is if it includes any of those included in the "Similar To Name" list where by default the Name value is included as the first element. This approach improves the usability of each "asset" created because, instead of starting from a new one, we will be able to continue configuring an existing one, more adapted to the nomenclatures of multiple animation artists with whom I have worked previously. In this way I will be able to improve an asset configuration that adapts to the nomenclatures of more and more artists, being able to extract the three levels of information we are looking for from all of them. For example, in the name of the animation when receiving damage, one artist includes the word "hit", another "damage", etc.

 

All processes using this configuration asset are performed in the editor, so a more versatile configuration, which detects more keywords, will be slower to process the data than one more adapted to an artist with "Similar To Name" lists composed of a single element, but this does not affect the "runtime" and choose between processing the renaming of 500 "AnimationClip" in 5 minutes or 10 minutes depending on a more specific or more versatile configuration asset, ends up being a personal choice, being both viable.

 

Finally, in each category we must choose an "Animation Param Type" among 3 options:

  1. "Bool". For those animations that are reproduced in "loop" from the moment I click to start the action until I decide to finish it. "MOVE", "CROUCH", "RUN", etc.
  2. "Trigger". For those animations that are played only once when I start the action. "ATTACK", "HIT", "JUMP", etc.
  3. "None". Special case for the "IDLE" state from which no transition starts or in its case of some animation that you want to call for some reason directly with "animator.Play(string clipName)", leaving its management outside the parameter system.

 

Internally, as a design decision of "EASY ANIMATOR CONTROLLER", it was decided to reduce the user's choices regarding the presetting of each main animation category, to the choice of an "Animation Param Type". Analyzing design patterns of many creators in their "AnimatorController", we came to the conclusion, later confirmed in the testing phase, that the following approach allows us to create new functional "AnimatorController" that represent a very advanced starting point, with the only effort of pressing a button.

 

The approach is: Starting from a general scheme in which all the states created from the renamed “AnimatorClips" to be used, will have a transition from "from any state" and a second one to "Idle state" and that what we choose in the configuration "asset", is the type of parameter that will allow us to control the flow of animations through these two transitions for each state created. In the data structures created, the appropriate index to find an animation that meets a basic and additional information, also gives us access to the parameter created in the state within the "AnimatorController" associated with that animation, so again we avoid the use of "magic strings".

 

For a developer looking for a simple solution, the result is fully functional, and for one looking for something more specific the result will be a very advanced starting point from which to perform a detailed calibration to achieve the desired result. In both cases, the time and effort spent using "EASY ANIMATOR CONTROLLER" is minimal.

 

"Idle state" will be the only state created without presetting any transitions and parameters associated with another state because it is set to "Animation Param Type" type "none".

 

The following configuration section, in the case of working with 3d models (working with 2d Sprite "animations" there is no setter for the equivalent variable), will set the variables "ModelImporterClipAnimation.loopTime" and "ModelImporterClipAnimation.loopPose" to true or false depending on whether the name of the "MAIN_ANIMATION_CATEGORIES" is included or not in this list.

In the next section “INPUT_DIRECTION_ADITIONAL_INFO” the main categories and the “Similar To Names” are established but in this case of the additional “Directional Input” type information (UP, DOWN, RIGHT, LEFT, SIDE). If it exists, it is added to the basic information in the ranoimming process (EX. MOVE_RIGHT, MOVE_UP). The following categories are included in the image by default. If it does not belong to any category, it is assigned the value “NODIR”.

Again, the "Similar To Name" lists will bring versatility to an asset so that it can adapt to different nomenclatures of different artists.

In the next section “POSITION_STATE_ADITIONAL_INFO” the main categories and the “Similar To Names” are established but in this case of the additional information of type “Position State” (IN-AIR, CROUCHING, DASHING, SWIMMING, CLIMBING, etc). If it exists, it is added to the basic information + additional information of type “Directional Input” (EX. MOVE_RIGHT_SWIMMING, MOVE_SIDE_CROUCHING). The following default categories are included in the image. In case of not belonging to any category, the value “NOPOS” is assigned.

Again, the "Similar To Name" lists will bring versatility to an asset so that it can be adapted to different nomenclatures of different artists.

The remaining configuration categories have the function of referencing the elements that we will need later. In this way it is easier to know, when we do not reach the desired result, what is failing because, having a list with all the necessary ingredients is easy to see if any is missing and if they are all it is easier to analyze what is failing. In addition to making it easier to ensure that all the ingredients are there, these references make it easier to scale the process, so I can apply "EASY ANIMATOR CONTROLLER" to one or 100 models by iterating these lists of references to necessary elements.

 

First, we have the "MODELS" section, that is, the "GameObjects" I want to animate with "EASY ANIMATOR CONTROLLER".

Secondly, we have the "RESOURCES_FOLDERS_PATHS" that are the paths from the "Resources folder" where I will find the AnimationClips" that we want to use in each model or GameObject. We should create the folders referenced within the "Resources" with the animations that the system expects to find in each case.

Each "RESOURCES_FOLDER_PATH" can be set manually but normally there is a main folder for each artist and several animation packs inside this main folder. The system will assign a path from the "Resources" folder resulting from adding to the variable "Main Animations Folder Folder Name In Resources" the name of each model in the MODELS list. Sometimes it is very useful because the artists create example "prefabs" with the same name as each folder that includes the "AnimationClips" of each pack as in the case of the example and other times we have to set the path manually. In section - THE EDITOR MODE PHASE. USE THE "CNBANIMADAPTER" COMPONENT - we explain how to use this functionality.

 

Secondly, we have the list with reference to as many "RuntimeAnimatorControllers" as models or "GameObjects" to animate we have. If I want to animate 11 "GameObjects" as in the example, in a folder I will create 11 new "RuntimeAnimatorControllers" and assign them in this list. The RuntimeAnimatorControllers will be renamed automatically when they are assigned to the corresponding "Animator component" in each case.

In the fourth and last reference field, "ACTUALIZE_CNBANIMLINKER_COMPONENT", we create a list with a "bool" type variable for each model. If "true" in the first element and false in the rest, the changes you make, will make again the calculations for that model and not for all, allowing this selective functionality. When using the system for the first time all variables must be set to true to create new AnimationControllers in all GameObjects to be animated. Sometimes it seems that the system does not work and it is that all the "bool" are set to "false" or only the one from which we are expecting a result that does not occur. It is like a selective activator / deactivator of "EASY ANIMATOR CONTROLLER". In section - THE EDITOR MODE PHASE. USE THE "CNBANIMADAPTER" COMPONENT-, we explain how to set all the "bool" to "true" or "false" by pressing a button, functionality proposed because sometimes if you work with a large number of models to animate can be useful.


Crea tu propia página web con Webador