- Home /
Animator transition conditionals is OR possible, or only and?
I want one idle animation to be called if any of a number of conditions are met. Is this possible from within the transition conditions inspector panel?
Answer by asecretspot · Jan 07, 2015 at 07:16 AM
I may be misunderstanding what you are saying but... you can add multiple transitions between two animations and set them to be activated through different conditions. You may need to be more specific with your question.
I have a 2d character that can face in 8 directions, with a different walk animation for each direction. I only have 2 idle animations, facing either forward or backward. I want it so that if I'm facing front-left, front or front-right and not moving, then to play the front facing idle animation. If I'm facing back-left, back or back-right, then to play the back facing idle animation. I can't figure out how to, or if it's possible to, use OR conditions in the transition panel.
If I understand you correctly it shouldn't be that difficult to get what you are trying to do. You just have to set your transitions properly. An OR condition could easily be simulated with an animator bool but I prefer not to code if there are ways around it.
You have to make it so your idle animations don't transition to each other but everything else should be able to transition to one other. I didn't add it to the quick picture but the back idle should be able to transition to the front animations as well I'm guessing but the picture would have gotten too messy.
Answer by hersheys72 · Aug 19, 2016 at 06:06 AM
I had this same issue, it would be nice if they had the OR option!
The work around I had was simply to just add another transition which both linked to the same node.
EG Node 1 =Attack1, Node 2 = Attack2 Two parameters : AttackTrigger1, AttackTrigger2 from Attack1 node to Attack2 node create two seperate transitions first: AttackTrigger1 , second: AttackTrigger2 which will act the same as if from Node1 IF AttackTrigger1 OR AttackTrigger2 is triggered it will transition to Node 2
But this would only work for a one-way transition like "Fire" or "Jump".
This wouldn't work for an ongoing animation that needs a transition in and a transition out like "Walking", as for example if you used two separate in-transitions and out-transitions from "Walking" to "Idle"
Bool of walking - true goes to walking, false leaves and goes to idle. Float of Speed - abs. value greater than 0.01 goes to walking, less goes to idle.
If one gets triggered (speed) and goes to walking, the bool for walking would still bring it back to idle and it would get all jumpy.
You could just put the two separate conditions in your script and write the OR statement there.
Example, in Update() you could have: if (condition1 or condition2) anim.SetBool("name",true) else //set it to false
This would mean you could use a single boolean as a condition even though it is really checking an OR between two conditions in your script.
Answer by Orr10c · Oct 13, 2017 at 04:01 PM
Correct me if I'm wrong but I think you can simply add a number of transitions from one state to another and that should give you an OR effect. Hope this helped.
Answer by rlmod17 · Mar 10, 2018 at 02:19 PM
Just use multiple transitions, if you add another one between 2 states, they act as or.
Answer by Dorthonion · Jul 05, 2017 at 12:31 PM
You can derive 'OR' from 'AND'
(A OR B) is the same as NOT ((NOT A) AND (NOT B))
This approach isn't possible within the animator, because there's no way to apply the outer NOT operator to (NOT A) AND (NOT B)
hersheys72's answer works fine