The question is answered, right answer was accepted
Getting Condition Value From Animator Transition in Script?
So, I'm really wanting to somehow obtain an animation transition's condition value in script, but I'm not coming out with any answers as to how I could do this.
To be clear, I'm trying to get the value that the condition needs to be to do a transition, not what the condition variable actually is. And I'm not doing this when I'm animating, I'm doing this for initialization.
For full context, I've got actions which are simply objects representing an animation the player might do. Each action has a corresponding state in the animator. Each state in the animator has several transitions leading to other attacks using an integer parameter. However, I require a representative for each of these "combo actions" an action has at run time. I'm currently getting by with essentially duplicating stuff I already know - based on the transitions an action has going out and using the integer value as an index, on each action resource I create an array of all the actions that it combos with.
Now, obviously, if I'm doing this for every action this could get tedious real quick, and since I'm already using the logic of an array to determine combos in the animator I figure it should be trivial to just initialize each action resource based on the info already in the animator - for each state, I could check the state's transitions and assign each action resource's combo array based on that information.
That's what I thought. I'm able to check through each and every transition of a state, and obtain the corresponding destination state, but I can't figure out how I can get the condition information I need. The AnimatorCondition class paradoxically has nothing I can see for identifying the condition.
So, I have my array of combo actions, but I don't know what indices they should be. That's where I'm stuck now.
And, I suppose I should admit that what I have does work, and it works well enough. But I'd really like to set up each attack once and be able to keep on going, rather than spending time duplicating data the engine should already know. If anybody has any idea how I could achieve this or something similar, I'd be very grateful.
As an aside, I know I could use Play or Crossfade to work backwards from my logic here, but my contention with that is that I'd have less control of the specifics of each attack's transition. Ideally, I'd like to have specific control how each attack transitions into the next. The animator allows this to happen easily, potentially allowing an animator to fine-tune how transitions, well, transition, all on their own. I'd preferably like to keep that elegance.
If it still isn't clear to you what I'm trying to do, I made a couple short videos to explain the whole thing: https://cdn.discordapp.com/attachments/469139531250008065/626846720738983966/explain1.mp4 https://cdn.discordapp.com/attachments/469139531250008065/626847560618868736/explain2.mp4
Answer by Tyooo · Sep 26, 2019 at 09:43 PM
Okay, I feel like a fool. An Index Out of Bounds exception was actually causing my test with AnimatorCondition not to complete and I hadn't noticed. I was totally mistaken - the threshold parameter was exactly what I was looking for. It sends you the value a transition is looking for in its condition. I spent hours wracking myself about this. Gah.